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

Fix persisting-state spelling and grammar #31

Merged
merged 1 commit into from
Aug 7, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions app/quick-start/persisting-state/markdown.ts
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.
`;