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

Do not try to batch updates in React >= 18 #5460

Merged
merged 3 commits into from
Jun 21, 2023

Conversation

12joan
Copy link
Contributor

@12joan 12joan commented Jun 21, 2023

Description
Checks if React.version is < 18 before calling unstable_batchedUpdates in with-react.ts.

Context
Updates are batched automatically in React >= 18. Calling unstable_batchedUpdates in React 18 produces an error in some circumstances:

[1] - error unhandledRejection: Error [TypeError]: ReactDOM__default.default.unstable_batchedUpdates is not a function
[1]     at e.onChange (webpack-internal:///(sc_client)/../../node_modules/slate-react/dist/index.js:5747:34)
[1]     at eval (webpack-internal:///(sc_client)/../../node_modules/slate/dist/index.js:3006:14) {
[1]   digest: undefined
[1] }

Environment
The above error was observed in the following environment:

react 18.2.0
react-dom 18.2.0
slate 0.94.1
slate-react 0.97.0

Checks

  • The new code matches the existing patterns and styles.
  • The tests pass with yarn test.
  • The linter passes with yarn lint. (Fix errors with yarn fix.)
  • The relevant examples still work. (Run examples with yarn start.)
  • You've added a changeset if changing functionality. (Add one with yarn changeset add.)

@changeset-bot
Copy link

changeset-bot bot commented Jun 21, 2023

🦋 Changeset detected

Latest commit: 8da6899

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
slate-react Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@dylans dylans merged commit 5339544 into ianstormtaylor:main Jun 21, 2023
12 checks passed
@github-actions github-actions bot mentioned this pull request Jun 21, 2023
@12joan 12joan deleted the bug/react-18-batched-updates branch June 21, 2023 18:32
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.

None yet

3 participants