react-immutable-render-mixin
react-immutable-render-mixin copied to clipboard
React state has changed, but ui is not updated
React state has changed, but ui is not updated
- platform verion
windows10
- react-immutable-render-mixin version
0.9.7
- code
import {shouldComponentUpdate} from 'react-immutable-render-mixin'
import ReactPullToRefresh from 'react-pull-to-refresh'
let count = 1
class Product extends Component {
constructor(props) {
super(props)
this.shouldComponentUpdate = shouldComponentUpdate.bind(this)
this.state = {
items: [
<div key={'item-' + count}>Item {count++}</div>
]
}
handleRefresh(resolve, reject) {
let self = this
console.log('handleRefresh...', this)
setTimeout(function () {
self.addItem() ? resolve() : reject()
console.log('is true: ', self.addItem())
}, 500)
}
addItem() {
console.log('addItem...')
this.state.items.push(<div key={'item-' + count}>Item {count++}</div>);
this.setState({
items: this.state.items
})
console.log('new items: ', this.state.items)
return true
}
render() {
return (
<div className="content-block">
<ReactPullToRefresh onRefresh={this.handleRefresh.bind(this)} style={{
textAlign: 'center'
}}>
<h3>Pull down to refresh</h3>
<div>
{this.state.items}
</div>
</ReactPullToRefresh>
</div>
)
}
}
}
React state has changed, but ui is not updated when I add react-immutable-render-mixin