3 ms·
That's very interesting. I have pretty much all my components in React. How can you use React / jsx with constexpr?
by vitriolum 6y ago
That's very interesting. I have pretty much all my components in React. How can you use React / jsx with constexpr?
- fctorial 6y agoFor react, you can use the `useEffect` hook to trigger compilation after the component renders: useEffect(() => window._ConstexprJS_.compile() , []) There's a babel jsx loader, that could be used. However, it dynamically compiles jsx to js and adds a script tag containing raw javascript to the DOM. You'll have to manually mark these new tags as 'constexpr', which shouldn't be too difficult. Or you could compile jsx with webpack and then use it. With constexpr.js, the final static page will look exactly like the original dynamic page, so using the webpack output should be easy. I might add an example in the next week.
- vitriolum 6y agoThanks! I guess an example would be really cool, give the amount of FE devs who already use React.