I have this code from courses, and how I understand my mistake, that ListView has been removed from ReactNative. How can I fix the problem?
I've tried to replace all ListView tag to FlatList. But didn't work out.
class LibraryList extends Component {
componentWillMount() {
const ds = new ListView.DataSource({
rowHasChanged: (r1, r2) => r1 !== r2
});
this.dataSource = ds.cloneWithRows(this.props.libraries);
}
renderRow(library) {
return <ListItem library={library} />;
}
render() {
return (
<ListView
dataSource={this.dataSource}
renderRow={this.renderRow}
/>
);
}
}
List VIew is deprecated in react native 0.60. So the quick fix is to use deprecated-react-native-listview
Need to add
import ListView from "deprecated-react-native-listview";
instead of
import ListView from from 'react-native';
https://www.npmjs.com/package/deprecated-react-native-listview
class LibraryList extends Component{
renderRow({item}) {
return <ListItem library = { item } />;
}
render() {
return(
<FlatList
data = {this.props.libraries}
renderItem = {this.renderRow}
/>
);
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With