我在状态中存储了一个布尔值,我只想在myBoolean的值为true或false时显示或隐藏dom的一部分
const { global } = useContext(globalContext);
...
return (
{global.myBoolean (
<p>Show me if true</p>
)}
)我得到的错误是
This expression is not callable.
Type 'Boolean' has no call signatures.发布于 2019-11-08 12:24:23
我认为你应该使用条件渲染,
{global.myBoolean && <p>Show me if true</p>}发布于 2019-11-08 12:24:33
我觉得你应该这样写,
return (
{global.myBoolean && (
<p>Show me if true</p>
)}
)希望能有所帮助
https://stackoverflow.com/questions/58760306
复制相似问题