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

React 18 #391

Merged
merged 9 commits into from
Oct 23, 2023
Merged

React 18 #391

merged 9 commits into from
Oct 23, 2023

Conversation

kimo-k
Copy link
Contributor

@kimo-k kimo-k commented Jul 3, 2023

No description provided.

React 18 introduces a new render API:

https://react.dev/blog/2022/03/29/react-v18#react-dom-client

The reagent.dom.client namespace wraps this new API. reagent.dom still
wraps the old one. React throws a deprecation warning if you use the
old API with React 18.

If a user uses the new API in their project, they will still get the
warning because of re-frame-10x using the old API. This is confusing.
It looks as if their code is suspect, when actually ours is.

re-frame-10x depends on the user's react version. That means we can't
predict whether the user will use React 17 or React 18, or which API
they will invoke. We can't just load reagent.dom.client, because it
only works with React 18. We can't load it conditionally based on the
react version, since it's a general limitation of cljs that we can't
require a namespace at runtime.

Added a second preload namespace. Since only the user can know which
API to use, we let them declare it themselves. The original preload
remains unchanged:

{:preloads [day8.re-frame-10x.preload]}

It calls the old API, which works in all cases. It throws the
deprecation warning if the user has React 18.

The new preload only works with React 18, using the new API properly:

{:preloads [day8.re-frame-10x.preload.react-18]}

Fixes #367
@kimo-k kimo-k marked this pull request as ready for review October 23, 2023 12:11
@kimo-k kimo-k merged commit 71eea6c into master Oct 23, 2023
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant