Reputation: 745
I need to show and hide a column depending on a boolean state. But it will only fire once.
I'm trying to set display none and block depending a boolean state, my app updates the boolean state but my column won't read it
<Row style={ (values.boolean ? styles.visible : styles.hidden) }>
I'm using the method setState to change my boolean:
this.setState({ boolean: Object.keys(response.tracks).length && Object.values(response.tracks).length ? true : false })
Edit: Sorry for the miss spell on the setstate, my code was right though
My app will actually update the state but the row just won't change
const styles = {
visible: {
display: 'block'
},
hidden: {
display: 'none'
}
}
Edit: I found the problem, I was trying to setState on the wrong path of a large object
Upvotes: 1
Views: 90
Reputation: 2200
As @Panther already answered to you:
this.setState gets a simple object with key-value as a parameter - all you need to do is to change the call to:
this.setState({ boolean: true })
Upvotes: 2