Skip to content

refactor(core): re-implement useAtom with useReducer#687

Merged
dai-shi merged 11 commits intomainfrom
barely-use-reducer
Sep 9, 2021
Merged

refactor(core): re-implement useAtom with useReducer#687
dai-shi merged 11 commits intomainfrom
barely-use-reducer

Conversation

@dai-shi
Copy link
Copy Markdown
Member

@dai-shi dai-shi commented Sep 5, 2021

uMS won't land, #686 doesn't work so far.
I feel like simpler solution with useReducer would work better.
This simplifies a lot. Also, fixes weird issues in devtools.

@vercel
Copy link
Copy Markdown

vercel Bot commented Sep 5, 2021

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/pmndrs/jotai/9Zch3BP9tA21Q54SQWYs4oCEXuEL
✅ Preview: https://jotai-git-barely-use-reducer-pmndrs.vercel.app

@dai-shi
Copy link
Copy Markdown
Member Author

dai-shi commented Sep 5, 2021

This improves https://github.com/dai-shi/will-this-react-global-state-work-in-concurrent-rendering results:

v1.3.2

  jotai
    with useTransition
      ✓ test 1: updated properly with transition (3562 ms)
      ✓ test 2: no tearing with transition (122 ms)
      ✓ test 3: ability to interrupt render
      ✕ test 4: proper branching with transition (7543 ms)
    with intensive auto increment
      ✕ test 5: updated properly with auto increment (13214 ms)
      ✕ test 6: no tearing with auto increment (4 ms)

33a40b0

  jotai
    with useTransition
      ✓ test 1: updated properly with transition (3555 ms)
      ✓ test 2: no tearing with transition (119 ms)
      ✓ test 3: ability to interrupt render (1 ms)
      ✕ test 4: proper branching with transition (8503 ms)
    with intensive auto increment
      ✓ test 5: updated properly with auto increment (3233 ms)
      ✕ test 6: no tearing with auto increment (2 ms)

@dai-shi
Copy link
Copy Markdown
Member Author

dai-shi commented Sep 5, 2021

I would like to test if react devtools work before merging. (codesandbox ci is not working. 😓 )

@codesandbox-ci
Copy link
Copy Markdown

codesandbox-ci Bot commented Sep 5, 2021

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 2e96c2c:

Sandbox Source
React Configuration
React Typescript Configuration
React Browserify Configuration
React Snowpack Configuration
Next.js Configuration

Comment thread src/devtools/useAtomsSnapshot.ts Outdated
Comment thread src/devtools/useAtomsSnapshot.ts Outdated
Comment thread src/devtools/useAtomsSnapshot.ts Outdated
Comment thread src/core/useAtom.ts
Co-authored-by: Mathis Møller <mmm@cryosinternational.com>
dai-shi and others added 2 commits September 8, 2021 20:32
Co-authored-by: Mathis Møller <mmm@cryosinternational.com>
Co-authored-by: Mathis Møller <mmm@cryosinternational.com>
Copy link
Copy Markdown
Collaborator

@Thisen Thisen left a comment

Choose a reason for hiding this comment

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

Looks good to me. Surprised that it didn't require test changes.

@dai-shi dai-shi merged commit c412d03 into main Sep 9, 2021
@dai-shi dai-shi deleted the barely-use-reducer branch September 9, 2021 00:24
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.

2 participants