以下是ViewProducts.js中的虚假代码
componentDidMount() {
return fetch('http://192.168.0.109/fyp/products.php')
.then((response) => response.json())
.then((responseJson) => {
let ds = new ListView.DataSource({rowHasChanged: (r1, r2) => r1 !== r2});
this.setState({
isLoading: false,
dataSource: ds.cloneWithRows(responseJson),
}, function() {
});
})
.catch((error) => {
console.error(error);
});
}