Equivalent boolean expressions not evaulated correctly
Hey,
First off, thanks for react-jsx-parser!
I've found a (possible) bug with boolean expressions. In a JSX string, this expression is not evaluated to the expected value:
...
{boundFunction(!boundValue)}
...
This is the workaround, which evaluates as expected:
...
{boundFunction(boundValue ? false : true)}
...
Am I missing anything?
Thanks again!
@jazzido - you are welcome! I hope the lib is helping you create cool stuff. :)
RE: boolean expressions, I just did a little initial testing, and it does seem like this is getting bound correctly, from what I can tell. I may not be understanding your example fully.
Here's what I can tell is working/parsing correctly:
jsx={'<div data-foo={!true} />'} // correctly renders data-foo="false"
jsx={'<div>{!true}</div>'} // correctly renders <div>false</div>
This tells me that the !{value} parsing is working correctly.
If what you're trying to do is actually invoke the function within JSX, however, you are likely to have a problem because the only things we parse, currently, are simple bindings. The lib does not act as an on-the-fly JS interpreter (which means that it will not correctly interpret your invocation of functions).
Thanks for your reply, @TroyAlford.
If what you're trying to do is actually invoke the function within JSX, however, you are likely to have a problem because the only think we parse, currently, are simple bindings. The lib does not act as an on-the-fly JS interpreter (which means that it will not correctly interpret your invocation of functions).
We're indeed invoking a function within JSX, which works as intended. Except for that weird behavior when interpreting its argument.
In thinking more about this - perhaps the issue, here, is that for some reason we aren't correctly handling the ! operator. The ternary operator is a different construct. :\