7 ms·
They are many libraries that use tagged template string to allow this, the most interesting to my eyes is the one made by preact dev. It's just named htm [0], i
by anton96 3y ago
They are many libraries that use tagged template string to allow this, the most interesting to my eyes is the one made by preact dev. It's just named htm [0], it's made by preact but it can totally be used with react.
The most interesting thing of this one is that uses no custom syntax for js variable, so @attribute something when you must pass an object as props.
0. https://github.com/developit/htm https://github.com/developit/htm
- throwaway290 3y agoIf it doesn’t have fragments, how do you implement something equivalent to this when mapping over items and every item has to output multiple roots? <React.Fragment key={idx}>
- anton96 3y agoYou can import the Fragment component of the React package or stack them directly, it works too. Normally, the empty bracket syntax should work, they have a few issues closed and open that talk about it in their repo.
- throwaway290 3y agoThanks! Interesting stuff