Answer the question
In order to leave comments, you need to log in
How to explain to the typescript that children will be rendered only if the condition passes?
There is a helper component that will render children only if the passed condition is true. There is a component, say UserProfile , that accepts the required user prop. And when I put this profile component inside my helper, the TS says that the object can be empty, but in the component it should not be empty. And if you use an ordinary ternark, then everything is fine. Is there any way to tell the TS that this component won't render it without data to avoid this TS error?
Answer the question
In order to leave comments, you need to log in
Without code examples, the only thing that can be said is go learn typescript.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question