I am trying to display a div on the same page when the user clicks on the link.
My HTML page:
<div class="stores"> <h1>Stores</h1> <ul class="stores"> <li><a href="#" onClick={this.onClick} >Store A</a></li> <li>Store B</li> <li>Store C</li> </ul> </div>
My components/store.js.jsx :
var Store = React.createClass({ getInitialState: function() { return { showStore: false }; }, onClick: function() { this.setState({ showStore: true }); }, render: function() { return( <div className="row account stores" style={{display: { this.state.showStore ? 'block' : 'none'} }}> <div>a lot more divs</div> </div> ); } });
But I get:
Syntax Error: unknown: Unexpected token
For this line:
style={{display: { this.state.showStore ? 'block' : 'none'} }}
How can I conclude conditionally inside a style?
javascript reactjs
Standardnerd
source share