feat(jsx/dom): improve compatibility with React - The 2024 May Update #2756
+552
−104
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Added hook
useInsertionEffect
useInsertionEffect
is implemented.https://ja.react.dev/reference/react/useInsertionEffect
Fixed Features
createPortal
When
createPortal
was called repeatedly in the same context, the DOM was not updated correctly.fixed in 8974135.
Update when
key
attribute is not specifiedAdjusted the rules for finding old elements when the key attribute is not specified so that the behavior is more like React. efb876e
Attribute name for SVGElement
SVGElement has a variety of attribute names, some are camel cases, some are kebab cases. So far, we have not converted to Kebab case, but now we convert to Kebab case as well as React. a036181
https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute
Multiple uses of children
It did not work correctly when children were used multiple times within a single component, as in the following test case, which has been fixed.
https://github.com/usualoma/hono/blob/8f6639f218c768beae414a78d13271d86e6007b5/src/jsx/dom/index.test.tsx#L439-L444
b19749b
Cautions for updating
I don't think there is a breaking change since it is the addition of one hook and a minor bug fix. However, for 8974135, there is a slight possibility that "previously the bug resulted in the expected result, but the correction results in an unexpected result". Therefore, I think this should be in the minor release, not in the patch release.
What did I use to verify?
https://ui.shadcn.com/docs/components/toast
https://ui.shadcn.com/docs/components/tooltip
These two UI components were verified in the following repositories
https://github.com/usualoma/hono-react-compat-demo
The author should do the following, if applicable
bun denoify
to generate files for Denobun run format:fix && bun run lint:fix
to format the code