31 ms·
Yeah the use of eval is purely to get it working today. The ideal would be to just change the JSX parser to place whatever is in the JSX tag directly. That woul
by tolmasky 11y ago
Yeah the use of eval is purely to get it working today. The ideal would be to just change the JSX parser to place whatever is in the JSX tag directly. That would also give you arbitrary expressions:
<memoize(f) key = "value"/>
<compose(f,g) key = "value" />
If you look at the implementation in the repo, you'll see its actually a little more complex than just eval now (since JSX will pass the actual reference when the tag name starts with a capital letter), but again this was solely to provide something that people could use with their existing Babel implementations and a simple require.
- kbenson 11y agoCouldn't you get around using eval by just use an object and register methods on it, instead of global functions, essentially using the object as a namespace? Instead of /* @jsx ((a,b)=>(eval(a)(b))) */ You would have /* @jsx ((a,b)=>(MyJSX[a](b))) */ And then just build your functions on top of the MyJSX object?
- WorldMaker 11y agoYep, that's essentially where I was leading.
- kbenson 11y agoAh, I actually missed that last part of your original comment, or I wouldn't have felt the need to comment myself. So much for reading comprehension on my part. ;)