Skip to content

Commit

Permalink
updated entries check
Browse files Browse the repository at this point in the history
  • Loading branch information
overthemike committed Oct 12, 2024
1 parent b3fd463 commit 8e5909a
Showing 1 changed file with 35 additions and 13 deletions.
48 changes: 35 additions & 13 deletions examples/test/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,19 @@ import { useSnapshot, proxy, subscribe } from '../../../dist/esm/index.mjs'
import { proxyMap } from '../../../dist/esm/utils.mjs'

const state = proxyMap()
const k1 = {}
state.set(k1, {
foo: 'bar',
})
const k1 = 'k1'
const k2 = 'k2'
state.set(k1, 'hello')

const App = () => {
const snap = useSnapshot(state)
const handleClick = () => {
state.delete(k1)
state.set('foo', 'asdf')
//state.delete(k1);
state.set(k2, 'hey')
}

useEffect(() => {
console.log(snap)
}, [snap])
console.log(snap.get(k1) === k1)
return (
<>
<p>{snap.has(k1) ? 'yes k1' : 'no k1'}</p>
<p>{snap.has('foo') ? 'foo' : 'no foo'}</p>
<p>{snap.has(k2) ? 'yes' : 'no'}</p>
<button onClick={handleClick}>Click Me</button>
<div>{Math.random()}</div>
</>
Expand All @@ -31,6 +24,35 @@ const App = () => {

export default App

// const state = proxyMap()
// const k1 = {}
// state.set(k1, {
// foo: 'bar',
// })

// const App = () => {
// const snap = useSnapshot(state)
// const handleClick = () => {
// state.delete(k1)
// state.set('foo', 'asdf')
// }

// useEffect(() => {
// console.log(snap)
// }, [snap])
// console.log(snap.get(k1) === k1)
// return (
// <>
// <p>{snap.has(k1) ? 'yes k1' : 'no k1'}</p>
// <p>{snap.has('foo') ? 'foo' : 'no foo'}</p>
// <button onClick={handleClick}>Click Me</button>
// <div>{Math.random()}</div>
// </>
// )
// }

// export default App

// const state = proxyMap([
// ['first', 0],
// ['fdsa', 1],
Expand Down

0 comments on commit 8e5909a

Please sign in to comment.