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(core): Move useAtomValue and useSetAtom to core #989

Merged
merged 13 commits into from Feb 11, 2022

Conversation

Thisen
Copy link
Collaborator

@Thisen Thisen commented Jan 29, 2022

This change renames useUpdateAtom to useSetAtom and moves useAtomValue and useSetAtom to core.
The hooks are still exported from jotai/utils with original names for backwards compatibility.

  • Impl
  • Tests

Move useAtomValue and useSetAtom to core
@vercel
Copy link

vercel bot commented Jan 29, 2022

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/3a9FGaH87YBRzfecnByEPna4CEAk
✅ Preview: https://jotai-git-refactor-use-atom-value-use-set-atom-core-pmndrs.vercel.app

@codesandbox-ci
Copy link

codesandbox-ci bot commented Jan 29, 2022

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 261fe97:

Sandbox Source
React Configuration
React Typescript Configuration
React Browserify Configuration
React Snowpack Configuration
Next.js Configuration
Next.js with custom Babel config Configuration
React with custom Babel config Configuration

@github-actions
Copy link

github-actions bot commented Jan 29, 2022

Size Change: +367 B (0%)

Total Size: 130 kB

Filename Size Change
dist/esm/index.js 5.49 kB +42 B (+1%)
dist/esm/utils.js 4.63 kB +4 B (0%)
dist/index.js 6.29 kB +41 B (+1%)
dist/system/index.development.js 5.73 kB +53 B (+1%)
dist/system/index.production.js 3.1 kB +58 B (+2%)
dist/system/utils.production.js 3.24 kB +19 B (+1%)
dist/umd/index.development.js 6.4 kB +41 B (+1%)
dist/umd/index.production.js 3.34 kB +62 B (+2%)
dist/umd/utils.development.js 6.01 kB +6 B (0%)
dist/umd/utils.production.js 3.74 kB +26 B (+1%)
dist/utils.js 5.83 kB +15 B (0%)
ℹ️ View Unchanged
Filename Size
dist/babel/plugin-debug-label.js 794 B
dist/babel/plugin-react-refresh.js 1.01 kB
dist/babel/preset.js 1.26 kB
dist/devtools.js 3.25 kB
dist/esm/babel/plugin-debug-label.js 622 B
dist/esm/babel/plugin-react-refresh.js 831 B
dist/esm/babel/preset.js 1.08 kB
dist/esm/devtools.js 2.48 kB
dist/esm/immer.js 616 B
dist/esm/optics.js 661 B
dist/esm/query.js 1.25 kB
dist/esm/redux.js 251 B
dist/esm/urql.js 1.49 kB
dist/esm/valtio.js 526 B
dist/esm/xstate.js 1.13 kB
dist/esm/zustand.js 284 B
dist/immer.js 732 B
dist/optics.js 938 B
dist/query.js 1.36 kB
dist/redux.js 314 B
dist/system/babel/plugin-debug-label.development.js 723 B
dist/system/babel/plugin-debug-label.production.js 544 B
dist/system/babel/plugin-react-refresh.development.js 934 B
dist/system/babel/plugin-react-refresh.production.js 726 B
dist/system/babel/preset.development.js 1.18 kB
dist/system/babel/preset.production.js 927 B
dist/system/devtools.development.js 2.64 kB
dist/system/devtools.production.js 1.83 kB
dist/system/immer.development.js 739 B
dist/system/immer.production.js 461 B
dist/system/optics.development.js 765 B
dist/system/optics.production.js 456 B
dist/system/query.development.js 1.4 kB
dist/system/query.production.js 963 B
dist/system/redux.development.js 339 B
dist/system/redux.production.js 217 B
dist/system/urql.development.js 1.64 kB
dist/system/urql.production.js 1.19 kB
dist/system/utils.development.js 4.94 kB
dist/system/valtio.development.js 639 B
dist/system/valtio.production.js 402 B
dist/system/xstate.development.js 1.25 kB
dist/system/xstate.production.js 805 B
dist/system/zustand.development.js 372 B
dist/system/zustand.production.js 235 B
dist/umd/babel/plugin-debug-label.development.js 947 B
dist/umd/babel/plugin-debug-label.production.js 696 B
dist/umd/babel/plugin-react-refresh.development.js 1.16 kB
dist/umd/babel/plugin-react-refresh.production.js 856 B
dist/umd/babel/preset.development.js 1.4 kB
dist/umd/babel/preset.production.js 1.05 kB
dist/umd/devtools.development.js 3.38 kB
dist/umd/devtools.production.js 2.26 kB
dist/umd/immer.development.js 878 B
dist/umd/immer.production.js 576 B
dist/umd/optics.development.js 1.08 kB
dist/umd/optics.production.js 671 B
dist/umd/query.development.js 1.5 kB
dist/umd/query.production.js 1.03 kB
dist/umd/redux.development.js 454 B
dist/umd/redux.production.js 322 B
dist/umd/urql.development.js 1.69 kB
dist/umd/urql.production.js 1.16 kB
dist/umd/valtio.development.js 722 B
dist/umd/valtio.production.js 500 B
dist/umd/xstate.development.js 1.33 kB
dist/umd/xstate.production.js 845 B
dist/umd/zustand.development.js 479 B
dist/umd/zustand.production.js 334 B
dist/urql.js 1.54 kB
dist/valtio.js 586 B
dist/xstate.js 1.19 kB
dist/zustand.js 344 B

compressed-size-action

@Thisen
Copy link
Collaborator Author

Thisen commented Jan 29, 2022

@dai-shi @sandren I have yet to change the docs, because I'm unsure how we want to tackle it.
How should leave it for another PR?

If not, where do we want to place the sections about useAtomValue and useSetAtom inside the docs? There's no obvious place for it.

I think we should leave a section in utils about them, that says we're deprecated and should be imported from jotai.

Let me know your thoughts.

Copy link
Member

@dai-shi dai-shi left a comment

Choose a reason for hiding this comment

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

Cool. Added some comments. Surprised with the number of files changed, and found they are tests. 😅

src/utils/useAtomValue.ts Outdated Show resolved Hide resolved
src/core/useAtomValue.ts Outdated Show resolved Hide resolved
@dai-shi dai-shi added this to the v1.6.0 milestone Jan 29, 2022
@dai-shi dai-shi linked an issue Jan 30, 2022 that may be closed by this pull request
@dai-shi
Copy link
Member

dai-shi commented Jan 30, 2022

@dai-shi @sandren I have yet to change the docs, because I'm unsure how we want to tackle it. How should leave it for another PR?

It can be another PR, but we would like to do it soon. I'm not merging this PR soon, so until then we can work on docs in this PR.

So, my idea is to modify this page https://jotai.org/docs/basics/primitives.
Split into two sections and describe the core APIs:

Basic APIs: atom, useAtom
Additional APIs: Provider, useAtomValue, useSetAtom

It's important to show that first thing to learn is atom/useAtom, and only reach to the additional APIs, when necessary.

Also, modify the API page: https://jotai.org/docs/api/core
Maybe, for additional APIs, we don't describe details in the Primitives page, but just an introduction and link to the Core API page.

As for Utils, we don't deprecate useAtomValue/useUpdateAtom in jotai/utils for now. So, in docs (https://jotai.org/docs/utils/use-atom-value, https://jotai.org/docs/utils/use-update-atom), just say we have the same api in core and add links.

Copy link
Member

@dai-shi dai-shi left a comment

Choose a reason for hiding this comment

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

Sorry for nits, but important. Please also check the conflicts.

src/core/useAtom.ts Show resolved Hide resolved
src/core/useAtom.ts Outdated Show resolved Hide resolved
src/core/useAtomValue.ts Outdated Show resolved Hide resolved
src/core/useAtom.ts Outdated Show resolved Hide resolved
@dai-shi
Copy link
Member

dai-shi commented Jan 31, 2022

Attempted import error: 'useSetAtom' is not exported from 'jotai' (imported as 'useSetAtom').

☝️ This is an error from Vercel deploy log. Seems like a tough one? cc @sandren

src/core/useSetAtom.ts Outdated Show resolved Hide resolved
website/src/components/docs.js Outdated Show resolved Hide resolved
Copy link
Member

@dai-shi dai-shi left a comment

Choose a reason for hiding this comment

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

Cool. This should be ready.
Let's work on docs in a separate PR.

@dai-shi dai-shi marked this pull request as ready for review February 6, 2022 04:49
@dai-shi dai-shi changed the title refactor(core): Move useAtomValue and useSetAtom to core feat(core): Move useAtomValue and useSetAtom to core Feb 10, 2022
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.

[RFC] useAtomValue and useSetAtom APIs in core
3 participants