Skip to content

Commit

Permalink
docs: fix bunshi example (#2937)
Browse files Browse the repository at this point in the history
  • Loading branch information
disjukr authored Jan 16, 2025
1 parent 5d31f51 commit 45feab1
Showing 1 changed file with 5 additions and 5 deletions.
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

0 comments on commit 45feab1

Please sign in to comment.