Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/441.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 使用ReactJs在redux状态下基于更新动态更改CSS属性_Javascript_Reactjs_Redux - Fatal编程技术网

Javascript 使用ReactJs在redux状态下基于更新动态更改CSS属性

Javascript 使用ReactJs在redux状态下基于更新动态更改CSS属性,javascript,reactjs,redux,Javascript,Reactjs,Redux,我有一个组件,我想在状态管理中的特定布尔值为真时显示它 return ( <> {showCustomers === true ? //Change the css property : console.log("Do nothing")} <div class={TestDisplay}> //Run a third party function that does multiple things

我有一个组件,我想在状态管理中的特定布尔值为真时显示它

  return (
    <>
    {showCustomers === true ? //Change the css property : console.log("Do nothing")}
        <div class={TestDisplay}>
        //Run a third party function that does multiple things but will also change the showCustomers to true.
    <ThirdParty></ThirdParty>
       </div>

   </>
)
所以我想做的是调用我无法控制的第三方组件。它将调用API并获得结果,然后最终将showCustomers状态变量更改为true。 然后我想将TestDisplay的css属性改为display block而不是none


这是可能的还是最好的运行组件的方式,但在showCustomers为真时显示它。

您应该能够执行以下操作

<div className={showCustomers === true ? TestDisplay : ""}>

通过这种方式,您可以删除和添加Div上的css类

<div className={showCustomers === true ? TestDisplay : ""}>