ich react-native
lerne und ich laufe zu dieser problem.I eine Klasse listView.js
haben, die eine ListView
enthält, die ich in index.android.js
zeigen wollen Der Fehler I bin immerReact-native eine Klasse importieren Listview angezeigt werden nicht funktioniert
The development server returned response error code: 500
URL: http://10.0.2.2:8081/index.android.bundle?platform=android&dev=true&hot=false&minify=false
Body:
{"from":"D:\\ReactNative\\first_app\\index.android.js","to":"./app/otherClass/listView","message":"Unable to resolve module `./app/otherClass/listView` from `D:\\ReactNative\\first_app\\index.android.js`: could not resolve `D:\\ReactNative\\first_app\\app\\otherClass\\listView' as a folder: it did not contain a package, nor an index file","name":"UnableToResolveError","type":"UnableToResolveError","errors":[{}]}
processBundleResult
BundleDownloader.java:172
access$100
BundleDownloader.java:38
execute
BundleDownloader.java:108
emitChunk
MultipartStreamReader.java:69
readAllParts
MultipartStreamReader.java:116
onResponse
BundleDownloader.java:96
execute
RealCall.java:135
run
NamedRunnable.java:32
runWorker
ThreadPoolExecutor.java:1113
run
ThreadPoolExecutor.java:588
run
Thread.java:818
Mein index.android.js
ist
import React, {Component} from 'react';
import {Text, View, AppRegistry, StyleSheet, TextInput,Switch} from 'react-native';
import listView from './app/otherClass/listView';
export default class first_app extends Component{
constructor(){
super();
this.state={
textValue:'Hello Mithun',
switchValue:false
}
}
switch_switch(value){
this.setState({
switchValue:value
});
}
onTextChange(value){
this.setState({
textValue:value
});
}
render(){
return(
<View>
<TextInput
placeholder="Enter some text"
value={this.state.textValue}
onChangeText={(value)=>this.onTextChange(value)}
/>
<Text>{this.state.textValue}</Text>
<Switch
value={this.state.switchValue}
onValueChange={(value)=> this.switch_switch(value)}
/>
<View>
<Text>{listView}</Text>
</View>
</View>
);
}
}
const style=StyleSheet.create({
myView: {
backgroundColor:'#00f'
},
myText: {
color: '#fff'
}
});
AppRegistry.registerComponent('first_app',()=>first_app);
Und mein listView.js
ist
import React, {Component} from 'react';
import {Text, View, AppRegistry, StyleSheet, TextInput,ListView} from 'react-native';
const users=[
{name:'Chiranjibi poudel'},
{name:'Rishi ram mukhiya'},
{name:'Mahendra Bhat'},
{name:'Surya Man Shrestha'}
]
export default class listView extends Component{
constructor(){
super();
const ds = new ListView.DataSource({rowHasChanged: (r1, r2) => r1 !== r2});
this.state={
userData: ds.cloneWithRows(users),
};
}
renderRow(users,sectionId,rowId,highlightRow){
return(
<View>
<Text>{users.name}</Text>
</View>
);
}
render(){
return(
<ListView
dataSource:{this.state.userData}
renderRow={(users) => <Text>{users}</Text>}
/>
);
}
}
AppRegistry.registerComponent('listView',()=>listView);
Der Pfad zur listView.js
ist absolut korrekt. Ich weiß nicht, wo ich falsch liege. Danke.