我尝试使用'change'侦听器和reloadData函数更新BillList的状态,但是我的尝试不好
export default class BillList extends React.Component {
constructor(props) {
super(props)
this.state = {
bills: []
}
this.reloadData()
realm.addListener('change',() => this.reloadData())
}
reloadData = () => {
queryAllBills().then(bills => {
this.setState({ bills });
}).catch(error => {
this.setState({ bills: [] });
});
}