You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently React exposes React.createElement(type, config, children) [1] to the outside world and internally calls the ReactElement(type, key, ref, self, source, owner, props) [2] function to create the actual Element instance.
React.createElement performs a copy of config to create props and extract key and ref.
In the ClojureScript world many libraries wrap React to provide a more cljs-idiomatic interface using CLJS persistent maps for props. The "hiccup"-syntax is very popular and convenient.
While this is far from ideal since we first allocate the CLJS data structures in addition to just ReactElements it is particular inconvenient that we convert the props data once and React does again. It would safe a lot of overhead if you could just call ReactElement directly saving a whole lot of work.
React.createElementRaw(type, key, ref, props) would be nice (as the others would be null anyways) or maybe under a more obscure name (to discourage use). It is fine if this is marked experimental and not otherwise officially supported.
Happy to create a matching PR if you folks agree to expose this somewhere.
If you're only optimizing it in production, would it make sense to skip React altogether and generate plain objects like Babel does with this plugin? See also #3228.
Currently React exposes
React.createElement(type, config, children)
[1] to the outside world and internally calls theReactElement(type, key, ref, self, source, owner, props)
[2] function to create the actual Element instance.React.createElement
performs a copy ofconfig
to createprops
and extractkey
andref
.In the ClojureScript world many libraries wrap React to provide a more cljs-idiomatic interface using CLJS persistent maps for props. The "hiccup"-syntax is very popular and convenient.
While this is far from ideal since we first allocate the CLJS data structures in addition to just
ReactElement
s it is particular inconvenient that we convert the props data once and React does again. It would safe a lot of overhead if you could just callReactElement
directly saving a whole lot of work.React.createElementRaw(type, key, ref, props)
would be nice (as the others would benull
anyways) or maybe under a more obscure name (to discourage use). It is fine if this is marked experimental and not otherwise officially supported.Happy to create a matching PR if you folks agree to expose this somewhere.
[1]
react/src/isomorphic/classic/element/ReactElement.js
Lines 183 to 265 in 6810627
[2]
react/src/isomorphic/classic/element/ReactElement.js
Line 117 in 6810627
The text was updated successfully, but these errors were encountered: