-
-
Notifications
You must be signed in to change notification settings - Fork 616
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
docs: using createStore to interact with atoms outside React #2445
docs: using createStore to interact with atoms outside React #2445
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for working on this.
It's bare minimum, but a good start.
|
||
## createStore | ||
|
||
[`createStore`](../core/store) provides a store interface that can be used to store your atoms. Using the store, you can access and mutate the state of your stored atoms from outside React. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need the extension for browsing in GitHub.
[`createStore`](../core/store) provides a store interface that can be used to store your atoms. Using the store, you can access and mutate the state of your stored atoms from outside React. | |
[`createStore`](../core/store.mdx) provides a store interface that can be used to store your atoms. Using the store, you can access and mutate the state of your stored atoms from outside React. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's bare minimum, but a good start.
Is there anything else you would like me to add here?
Preview in LiveCodesLatest commit: 3c3a052
See documentations for usage instructions. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Please run prettier.
Oops my bad done |
[![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [@biomejs/biome](https://biomejs.dev) ([source](https://togithub.com/biomejs/biome/tree/HEAD/packages/@biomejs/biome)) | [`1.5.3` -> `1.6.1`](https://renovatebot.com/diffs/npm/@biomejs%2fbiome/1.5.3/1.6.1) | [![age](https://developer.mend.io/api/mc/badges/age/npm/@biomejs%2fbiome/1.6.1?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://developer.mend.io/api/mc/badges/adoption/npm/@biomejs%2fbiome/1.6.1?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://developer.mend.io/api/mc/badges/compatibility/npm/@biomejs%2fbiome/1.5.3/1.6.1?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/@biomejs%2fbiome/1.5.3/1.6.1?slim=true)](https://docs.renovatebot.com/merge-confidence/) | | [@types/node](https://togithub.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/node) ([source](https://togithub.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/node)) | [`18.19.22` -> `18.19.24`](https://renovatebot.com/diffs/npm/@types%2fnode/18.19.22/18.19.24) | [![age](https://developer.mend.io/api/mc/badges/age/npm/@types%2fnode/18.19.24?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://developer.mend.io/api/mc/badges/adoption/npm/@types%2fnode/18.19.24?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://developer.mend.io/api/mc/badges/compatibility/npm/@types%2fnode/18.19.22/18.19.24?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/@types%2fnode/18.19.22/18.19.24?slim=true)](https://docs.renovatebot.com/merge-confidence/) | | [@types/react](https://togithub.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/react) ([source](https://togithub.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/react)) | [`18.2.64` -> `18.2.66`](https://renovatebot.com/diffs/npm/@types%2freact/18.2.64/18.2.66) | [![age](https://developer.mend.io/api/mc/badges/age/npm/@types%2freact/18.2.66?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://developer.mend.io/api/mc/badges/adoption/npm/@types%2freact/18.2.66?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://developer.mend.io/api/mc/badges/compatibility/npm/@types%2freact/18.2.64/18.2.66?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/@types%2freact/18.2.64/18.2.66?slim=true)](https://docs.renovatebot.com/merge-confidence/) | | [@types/react-dom](https://togithub.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/react-dom) ([source](https://togithub.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/react-dom)) | [`18.2.21` -> `18.2.22`](https://renovatebot.com/diffs/npm/@types%2freact-dom/18.2.21/18.2.22) | [![age](https://developer.mend.io/api/mc/badges/age/npm/@types%2freact-dom/18.2.22?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://developer.mend.io/api/mc/badges/adoption/npm/@types%2freact-dom/18.2.22?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://developer.mend.io/api/mc/badges/compatibility/npm/@types%2freact-dom/18.2.21/18.2.22?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/@types%2freact-dom/18.2.21/18.2.22?slim=true)](https://docs.renovatebot.com/merge-confidence/) | | [jotai](https://togithub.com/pmndrs/jotai) | [`2.7.0` -> `2.7.1`](https://renovatebot.com/diffs/npm/jotai/2.7.0/2.7.1) | [![age](https://developer.mend.io/api/mc/badges/age/npm/jotai/2.7.1?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://developer.mend.io/api/mc/badges/adoption/npm/jotai/2.7.1?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://developer.mend.io/api/mc/badges/compatibility/npm/jotai/2.7.0/2.7.1?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/jotai/2.7.0/2.7.1?slim=true)](https://docs.renovatebot.com/merge-confidence/) | | [postcss](https://postcss.org/) ([source](https://togithub.com/postcss/postcss)) | [`8.4.35` -> `8.4.36`](https://renovatebot.com/diffs/npm/postcss/8.4.35/8.4.36) | [![age](https://developer.mend.io/api/mc/badges/age/npm/postcss/8.4.36?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://developer.mend.io/api/mc/badges/adoption/npm/postcss/8.4.36?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://developer.mend.io/api/mc/badges/compatibility/npm/postcss/8.4.35/8.4.36?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/postcss/8.4.35/8.4.36?slim=true)](https://docs.renovatebot.com/merge-confidence/) | | [org.jetbrains.kotlin-wrappers:kotlin-wrappers-bom](https://togithub.com/JetBrains/kotlin-wrappers) | `1.0.0-pre.710` -> `1.0.0-pre.715` | [![age](https://developer.mend.io/api/mc/badges/age/maven/org.jetbrains.kotlin-wrappers:kotlin-wrappers-bom/1.0.0-pre.715?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://developer.mend.io/api/mc/badges/adoption/maven/org.jetbrains.kotlin-wrappers:kotlin-wrappers-bom/1.0.0-pre.715?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://developer.mend.io/api/mc/badges/compatibility/maven/org.jetbrains.kotlin-wrappers:kotlin-wrappers-bom/1.0.0-pre.710/1.0.0-pre.715?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/maven/org.jetbrains.kotlin-wrappers:kotlin-wrappers-bom/1.0.0-pre.710/1.0.0-pre.715?slim=true)](https://docs.renovatebot.com/merge-confidence/) | --- ### Release Notes <details> <summary>biomejs/biome (@​biomejs/biome)</summary> ### [`v1.6.1`](https://togithub.com/biomejs/biome/blob/HEAD/CHANGELOG.md#161-2024-03-12) [Compare Source](https://togithub.com/biomejs/biome/compare/560628b380b0b1f61303c8e5ca2175d3b4794089...4ed1cbe96bc9e6d7092e88dd0a54ff8ce78037e5) ##### CLI ##### Bug fixes - CLI is now able to automatically search and resolve `biome.jsonc` ([#​2008](https://togithub.com/biomejs/biome/issues/2008)). Contributed by [@​Sec-ant](https://togithub.com/Sec-ant) - Fix a false positive where some files were counted as "fixed" even though they weren't modified. Contributed by [@​ematipico](https://togithub.com/ematipico) ##### Configuration ##### Bug fixes - `json.formatter.trailingCommas` option now works in `overrides` ([#​2009](https://togithub.com/biomejs/biome/issues/2009)). Contributed by [@​Sec-ant](https://togithub.com/Sec-ant) ##### Linter ##### New features - Add rule [noDoneCallback](https://biomejs.dev/linter/rules/no-done-callback), this rule checks the function parameter of hooks & tests for use of the done argument, suggesting you return a promise instead. Contributed by [@​vasucp1207](https://togithub.com/vasucp1207) ```js beforeEach(done => { // ... }); ``` ##### Bug fixes - [useJsxKeyInIterable](https://biomejs.dev/linter/rules/use-jsx-key-in-iterable) now recognizes function bodies wrapped in parentheses ([#​2011](https://togithub.com/biomejs/biome/issues/2011)). Contributed by [@​Sec-ant](https://togithub.com/Sec-ant) - [useShorthandFunctionType](https://biomejs.dev/linter/rules/use-shorthand-function-type) now preserves type parameters of generic interfaces when applying fixes ([#​2015](https://togithub.com/biomejs/biome/issues/2015)). Contributed by [@​Sec-ant](https://togithub.com/Sec-ant) - Code fixes of [useImportType](https://biomejs.dev/linter/rules/use-import-type) and [useExportType](https://biomejs.dev/linter/rules/use-export-type) now handle multiline statements ([#​2041](https://togithub.com/biomejs/biome/issues/2041)). Contributed by [@​Conaclos](https://togithub.com/Conaclos) - [noRedeclare](https://biomejs.dev/linter/rules/no-redeclare) no longer reports type parameter and parameter with identical names ([#​1992](https://togithub.com/biomejs/biome/issues/1992)). The following code is no longer reported: ```ts function f<a>(a: a) {} ``` Contributed by [@​Conaclos](https://togithub.com/Conaclos) - [noRedeclare](https://biomejs.dev/linter/rules/no-redeclare) now reports duplicate type parameters in a same declaration. The following type parameters are now reported as a redeclaraion: ```ts function f<T, T>() {} ``` Contributed by [@​Conaclos](https://togithub.com/Conaclos) - [noUndeclaredDependencies](https://biomejs.dev/linter/rules/no-undeclared-dependencies/) now recognizes imports of subpath exports. E.g., the following import statements no longer report errors if `@mui/material` and `tailwindcss` are installed as dependencies: ```ts import Button from "@​mui/material/Button"; import { fontFamily } from "tailwindcss/defaultTheme"; ``` Contributed by [@​Sec-ant](https://togithub.com/Sec-ant) ##### Parser ##### Bug fixes - JavaScript lexer is now able to lex regular expression literals with escaped non-ascii chars ([#​1941](https://togithub.com/biomejs/biome/issues/1941)). Contributed by [@​Sec-ant](https://togithub.com/Sec-ant) ### [`v1.6.0`](https://togithub.com/biomejs/biome/blob/HEAD/CHANGELOG.md#160-2024-03-08) [Compare Source](https://togithub.com/biomejs/biome/compare/906de83449b5066554cd8e97c78a1f8e43749016...560628b380b0b1f61303c8e5ca2175d3b4794089) ##### Analyzer ##### New features - Add partial for `.astro` files. Biome is able to sort imports inside the frontmatter of the Astro files. Contributed by [@​ematipico](https://togithub.com/ematipico) </details> <details> <summary>pmndrs/jotai (jotai)</summary> ### [`v2.7.1`](https://togithub.com/pmndrs/jotai/releases/tag/v2.7.1) [Compare Source](https://togithub.com/pmndrs/jotai/compare/v2.7.0...v2.7.1) This fixes a regression in v2.7.0. #### What's Changed - fix(vanilla): store should flush pending write triggered asynchronously and indirectly by [@​iwoplaza](https://togithub.com/iwoplaza) in [https://github.com/pmndrs/jotai/pull/2451](https://togithub.com/pmndrs/jotai/pull/2451) - fix(utils): atomWithStorage to always run onMount by [@​dai-shi](https://togithub.com/dai-shi) in [https://github.com/pmndrs/jotai/pull/2455](https://togithub.com/pmndrs/jotai/pull/2455) #### New Contributors - [@​rothsandro](https://togithub.com/rothsandro) made their first contribution in [https://github.com/pmndrs/jotai/pull/2426](https://togithub.com/pmndrs/jotai/pull/2426) - [@​NehalDamania](https://togithub.com/NehalDamania) made their first contribution in [https://github.com/pmndrs/jotai/pull/2441](https://togithub.com/pmndrs/jotai/pull/2441) - [@​tien](https://togithub.com/tien) made their first contribution in [https://github.com/pmndrs/jotai/pull/2446](https://togithub.com/pmndrs/jotai/pull/2446) - [@​ashuvssut](https://togithub.com/ashuvssut) made their first contribution in [https://github.com/pmndrs/jotai/pull/2445](https://togithub.com/pmndrs/jotai/pull/2445) **Full Changelog**: pmndrs/jotai@v2.7.0...v2.7.1 </details> <details> <summary>postcss/postcss (postcss)</summary> ### [`v8.4.36`](https://togithub.com/postcss/postcss/blob/HEAD/CHANGELOG.md#8436) [Compare Source](https://togithub.com/postcss/postcss/compare/8.4.35...e5ad9394daf38d0ef4acd7065f219b3cddace1df) - Fixed `original.column are not numbers` error on broken previous source map. </details> --- ### Configuration 📅 **Schedule**: Branch creation - "after 1pm and before 5pm on Friday" in timezone Asia/Tokyo, Automerge - At any time (no schedule defined). 🚦 **Automerge**: Enabled. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 👻 **Immortal**: This PR will be recreated if closed unmerged. Get [config help](https://togithub.com/renovatebot/renovate/discussions) if that's undesired. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://developer.mend.io/github/turtton/volglass). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy4yNDUuMCIsInVwZGF0ZWRJblZlciI6IjM3LjI0NS4wIiwidGFyZ2V0QnJhbmNoIjoibWFpbiJ9--> Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Related Issues or Discussions
Summary
Added docs to explain how to interact with atoms outside React
This Codesandbox is used in the example: https://codesandbox.io/p/sandbox/practical-bardeen-2jvynm?file=%2Fsrc%2FApp.tsx%3A16%2C5
Check List
yarn run prettier
for formatting code and docs