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

docs: fix bunshi example #2937

Merged
merged 1 commit into from
Jan 16, 2025
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
10 changes: 5 additions & 5 deletions docs/extensions/scope.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,10 @@ npm install bunshi
import { atom, useAtom } from 'jotai'
import { molecule, useMolecule, createScope, ScopeProvider } from 'bunshi/react'

const InitialCountScope = createScope(0)
const InitialCountScope = createScope({ initialCount: 0 })
const countMolecule = molecule((getMol, getScope) => {
const initialCont = getScope(InitialCountScope)
return atom(initialCont)
const { initialCount } = getScope(InitialCountScope)
return atom(initialCount)
})

const Counter = () => {
Expand All @@ -133,12 +133,12 @@ const Counter = () => {
const App = () => (
<div>
<h1>With initial value 1</h1>
<ScopeProvider scope={InitialCountScope} value={1}>
<ScopeProvider scope={InitialCountScope} value={{ initialCount: 1 }}>
<Counter />
<Counter />
</ScopeProvider>
<h1>With initial value 2</h1>
<ScopeProvider scope={InitialCountScope} value={2}>
<ScopeProvider scope={InitialCountScope} value={{ initialCount: 2 }}>
<Counter />
<Counter />
</ScopeProvider>
Expand Down
Loading