-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #31 from KrastanD/KrastanD-patch-1
Fix persisting-state spelling and grammar
- Loading branch information
Showing
1 changed file
with
3 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,14 @@ | ||
export const markdown = ` | ||
# Persisting state value | ||
In this lesson, we take a look at how we can persist the state value to \`localStorage\` with jotai \`atoms\`. | ||
Persisting states to the \`localStorage\` can be challenging, maybe you want to persist user's preferences or data to hand them to users on thier next session. | ||
In this lesson, we will take a look at how we can persist the state value to \`localStorage\` with jotai \`atoms\`. | ||
Persisting state to \`localStorage\` can be challenging. You might want to persist the user's preferences or data for their next session. | ||
Jotai \`atomWithStorage\` is a special kind of atom that automatically syncs the value provided to it with localstorage or sessionStorage, and picks the value upon the first load automatically. It's available in the \`jotai/utils\` module. | ||
To persist our theme atom simply create it with the \`atomWithStorage\` atom. | ||
~~~js | ||
const theme = atomWithStorage('dark', false) | ||
~~~ | ||
Now, when you reload the preview section of editor you see that the theme matches with the value before the page reloads. | ||
Now, when you reload the preview section of the editor you will see that the theme matches the value from before the page reload. | ||
`; |