Skip to content

Commit

Permalink
docs: fix typo in how-valtio-works.mdx (#783)
Browse files Browse the repository at this point in the history
* docs: fix typo in how-valtio-works.mdx

* docs: fix typo in how-valtio-works.mdx
  • Loading branch information
Pulset authored Aug 31, 2023
1 parent 4f4404d commit 5398399
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions docs/how-tos/how-valtio-works.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ This is to describe the high level abstraction of valtio.
import { proxy, subscribe } from 'valtio'

const s1 = proxy({})
subscribe(s1, () => { console.log('s1 is changed!') })
subscribe(s1, () => {
console.log('s1 is changed!')
})
s1.a = 1 // s1 is changed!
++s1.a // s1 is changed!
delete s1.a // s1 is changed!
Expand All @@ -30,11 +32,15 @@ s1.b = 2 // (not changed)
s1.obj = {} // s1 is changed!
s1.obj.c = 3 // s1 is changed!
const s2 = s1.obj
subscribe(s2 () => { console.log('s2 is changed!') })
subscribe(s2, () => {
console.log('s2 is changed!')
})
s1.obj.d = 4 // s1 is changed! and s2 is changed!
s2.d = 5 // s1 is changed! and s2 is changed!
const s3 = proxy({})
subscribe(s3 () => { console.log('s3 is changed!') })
subscribe(s3, () => {
console.log('s3 is changed!')
})
s1.o = s3
s3.p = 'hello' // s1 is changed! and s3 is changed!
s2.q = s3
Expand Down

1 comment on commit 5398399

@vercel
Copy link

@vercel vercel bot commented on 5398399 Aug 31, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

valtio – ./

valtio-git-main-pmndrs.vercel.app
valtio-pmndrs.vercel.app
valtio.vercel.app
valtio.pmnd.rs

Please sign in to comment.