0
私は関数からリストビューを更新しようとしていますが、現在は更新されていません。ここに完全なソースコードがあります。ListViewデータソースが更新されていません - リアクションネイティブ
も私が間違って
import React, { Component } from 'react';
import {
AppRegistry,
ListView,
TextView,
Text,
View
} from 'react-native';
const ds = new ListView.DataSource({ rowHasChanged: (row1, row2) => row1 != row2 });
var myarray = [];
export default class filesix extends Component {
constructor() {
super();
this.state = {
dataSource: ds.cloneWithRows(myarray),
};
console.log(`ds const =${myarray}`);
}
componentDidMount() {
myarray = ['11', '22'];
console.log(myarray);
this.setState = ({
datasource: this.state.dataSource.cloneWithRows(myarray),
});
this.prepareDataSource();
console.log('this componentDidMount');
}
prepareDataSource() {
myarray = ['11', '22'];
console.log(myarray);
}
renderRow(rowData) {
return <Text>{JSON.stringify(rowData)}</Text>
}
render() {
return (
<View style={{ flex: 1, borderWidth: 2 }}>
<ListView
enableEmptySections={true}
dataSource={this.state.dataSource}
renderRow={this.renderRow}
/>
</View>
);
}
}
AppRegistry.registerComponent('filesix',() => filesix);
をやって何をすることを明記してください私はすでに値を更新するために、私の一日を過ごしたが、ない運が、私の理解を修正していないしてください。
更新されていないものはありますか?それらは2つの行をレンダリングしていますか? –
いいえ2行を表示しません –