reactjs - React Native MobX FlatList extraData -
i cannot rows re-render when observable variable changes. can see console log triggering , managecart function indeed working. problem rows not update. have tried setting extradata on flatlist extradata={this.props.mainstore.productdatasource.slice()} or without . slice() still not help.
managecart(id, type) { let tempone = this.props.mainstore.productdatasource.slice(); tempone.map((b, i) => { if (b.product_id === id) { b.qty = b.qty + 1; } }); this.props.mainstore.productdatasource = tempone; } _renderrow = ({ item }) => { return ( <productrow item={item} orientation={this.props.uistore.orientation} managecart={this.managecart} /> ) } render() { console.log(this.props.mainstore.productdatasource.slice()) return ( <view style={styles.container}> <statusbargray /> <fixedheader {...this.props} headerup={this.state.headerup} /> <flatlist onscroll={this.handlescroll.bind(this)} scrolleventthrottle={1} keyextractor={(_, i) => i} listheadercomponent={this._renderheader} data={this.props.mainstore.productdatasource.slice()} renderitem={this._renderrow} /> </view> ); }
Comments
Post a Comment