by koito17 · 3y ago · 0 comments
This worries me a bit because some React wrappers for ClojureScript expose macros that essentially compile to React.createElement() calls, which are now labelled as a legacy API.
It also looks like Class Components are officially deprecated, given that the documentation explicitly states they are not recommended for use in new code.
We're not removing createElement but I'd recommend to change your wrappers to the same compile output that the new JSX transform (introduced in 2020) uses: https://legacy.reactjs.org/blog/2020/09/22/introducing-the-n.... The new JSX compile target will allow us to do a bunch of optimizations in the future that createElement() can't.
I'll make a note of adding this to the docs.
In our embedded/plugin component scenario where we are given a <div> to load in, it appears we should replace our current pattern ReactDOM.render(React.createElement(... with createRoot(_jsx(....
Yeah you want
const root = createRoot(domNode) root.render(<Stuff />)
(or the JSX transform output equivalent)