-
Notifications
You must be signed in to change notification settings - Fork 440
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: replace React.createElement
with jsx runtime
#8043
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
1 Skipped Deployment
|
No changes to documentation |
Component Testing Report Updated Dec 18, 2024 9:13 AM (UTC) ✅ All Tests Passed -- expand for details
|
⚡️ Editor Performance ReportUpdated Wed, 18 Dec 2024 09:24:19 GMT
Detailed information🏠 Reference resultThe performance result of
🧪 Experiment resultThe performance result of this branch
📚 Glossary
|
47c9a69
to
0d9989b
Compare
a43fe42
to
6464d4a
Compare
@@ -82,7 +81,7 @@ export const ScrollContainer = forwardRef(function ScrollContainer<T extends Ele | |||
|
|||
return ( | |||
<ScrollContext.Provider value={childContext}> | |||
{createElement(as, {'ref': ref, 'data-testid': 'scroll-container', ...rest})} | |||
<As data-testid="scroll-container" {...rest} ref={ref} /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
6464d4a
to
27ccbab
Compare
27ccbab
to
408db0f
Compare
0304e80
to
439baf7
Compare
439baf7
to
c2c9262
Compare
c2c9262
to
6403511
Compare
6403511
to
fb66dfe
Compare
fb66dfe
to
118b135
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the detailed explanation! This looks good to me.
* next: (68 commits) fix(deps): update dependency @sanity/icons to ^3.5.5 (#8105) fix(deps): update dependency @sanity/ui to ^2.10.12 (#8108) fix(deps): update dependency react-rx to ^4.1.10 (#8109) chore(deps): update dependency @sanity/tsdoc to v1.0.153 (#8107) chore(deps): update typescript-tooling (#8104) fix(deps): update dependency @sanity/icons to ^3.5.5 (#8106) feat(typegen): add support for astro (#8098) chore(deps): update dependency turbo to ^2.3.3 (#8099) fix(deps): Update dev-non-major (#8100) fix: `WebSocket is closed before the connection is established` warning (#8042) v3.68.1 fix(deps): update dependency @sanity/presentation to v1.19.13 (#8102) v3.68.0 fix: use consistent `framer-motion` semver range (#8094) refactor(core): replace `PortableTextEditor` with `EditorProvider` (#8040) fix: improve `SanityDefaultPreview` memoization (#8049) fix: tooltip position in announcements popup (#8092) fix: replace useMemo with useState (#8095) fix: replace unsafe `useMemo` with `useState` (#8047) fix: replace `React.createElement` with jsx runtime (#8043) ...
Description
Before the JSX transform were introduced it didn't really matter if you called
React.createElement
directly, or if you used JSX.With
as input, you got
as output. In that world you might as well call it directly, as it's functionally equivalent:
Since then the entire ecosystem has moved to the jsx transform, that includes our vite when using
sanity dev|build|deploy
, as well as publishing libraries with@sanity/pkg-utils
, and most other build tooling like Parcel, tsup etc etc.With the new transform it's not just a new function being used, it's from a different, standalone export, and its function argument semantics are different:
On top of that, React 19 introduces new features that are only available if the
jsx-runtime
transform is used, which isn't supported withcreateElement
.For example using
ref
as a prop, instead of usingReact.forwardRef
, requires it:The React 19
<LoadingIcon />
only works if the JSX transform is used (repl):When using
createElement
it fails (repl):What to review
Is the linter rule addition that blocks
React.createElement
clear enough?Testing
If tests pass we should be good.
Notes for release
Replaced
React.createElement
calls in internals with the JSX runtime, unlocking the React 19 performance improvements to JSX, as well as the ability to useref
as a prop instead ofReact.forwardRef
wrappers.