Skip to content
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

feat(jsx/dom): improve compatibility with React - The 2024 May Update #2756

Merged
merged 7 commits into from
May 24, 2024

Conversation

usualoma
Copy link
Member

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 specified

Adjusted 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

  • Add tests
  • Run tests
  • bun denoify to generate files for Deno
  • bun run format:fix && bun run lint:fix to format the code

@yusukebe
Copy link
Member

@usualoma Thanks! I'll check it later.

@yusukebe yusukebe added the v4.4 label May 22, 2024
@yusukebe yusukebe changed the base branch from main to next May 22, 2024 20:38
@yusukebe
Copy link
Member

Hi @usualoma !

I've tried your project, but "Toast 2" and "Tooltip" are not working. Could you check them? I also tried using The Toast and Tooltip in shading/ui with this PR in my project, but it does not work well, though my setup may be wrong.

@usualoma
Copy link
Member Author

@yusukebe Thank you!

Hmmm, I wonder why.
The style is not applied, but I have it working as follows: the DOM has been changed as intended by the original library, I believe.

CleanShot.2024-05-24.at.08.17.47.mp4

I started over from git clone and got it working in the following 3 steps.

  1. git clone
  2. bun install
  3. npm run dev

If you were using bun install, maybe "hono": ". /hono.tgz", is strongly cached with absolute paths and may not be updated.
When I had that problem on my end, I solved it by deleting ~/.bun/install/cache and starting over.

@yusukebe
Copy link
Member

@usualoma

When I had that problem on my end, I solved it by deleting ~/.bun/install/cache and starting over.

Wow, it works after I've done this instruction! Thanks!

Copy link
Member

@yusukebe yusukebe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@yusukebe yusukebe merged commit 0726357 into honojs:next May 24, 2024
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants