How to CSS display:none within conditional with React JSX?

后端 未结 3 621
南笙
南笙 2021-01-31 07:46

I\'m trying to render a div on the same page when the user clicks on a link.

My HTML page:

Stores&l

3条回答
  •  星月不相逢
    2021-01-31 08:19

    This is due to incorrect usage of the ternary operator. See documentation here: https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Operators/Conditional_Operator

    You should not wrap it with {} as you have done.

    Try the following:

    style={{display: this.state.showStore ? 'block' : 'none' }}
    

提交回复
热议问题