Open afhammad opened 8 years ago
Do you mean like this?
// if you add `let unexpected` it doesn't fail.
return (
<Cond value={1}>
<Clause test={2}><h1>{unexpected}</h1></Clause> // <--- this breaks
<Clause test={1}><h1>expected</h1></Clause>
<Default><h1>default</h1></Default>
</Cond>
)
I don't think this can be done. It happens before react-cond is doing anything. Or do you have any idea how to fix it?
At the moment children of all clauses are evaluated. As you can imagine this can result in "Cannot read property.." when the data is not there since that clause should not be rendered.
Is it possible to only evaluate the children of a matching clause?