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 : ""}>