1

I have a boolean stored in state, and I simply want to show or hide part of the dom if the value of myBoolean is true or false

const { global } = useContext(globalContext);
...
return (
 {global.myBoolean (
   <p>Show me if true</p>
)}
)

the error im getting is

This expression is not callable.
  Type 'Boolean' has no call signatures.

2 Answers 2

3

I think you should use conditional rendering,

{global.myBoolean && <p>Show me if true</p>}
Sign up to request clarification or add additional context in comments.

Comments

2

I think you need to write it as this,

return (
 {global.myBoolean && (
  <p>Show me if true</p>
 )}
)

Hope it helps

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.