diff options
Diffstat (limited to 'examples/astro-nanostores/src/components/AdminsPreact.jsx')
-rw-r--r-- | examples/astro-nanostores/src/components/AdminsPreact.jsx | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/examples/astro-nanostores/src/components/AdminsPreact.jsx b/examples/astro-nanostores/src/components/AdminsPreact.jsx new file mode 100644 index 000000000..6c4a126ea --- /dev/null +++ b/examples/astro-nanostores/src/components/AdminsPreact.jsx @@ -0,0 +1,27 @@ +import { h, Fragment } from 'preact'; +import { useStore } from 'nanostores/preact' + +import { admins } from '../store/admins.js' +import { counter, increaseCounter, decreaseCounter } from '../store/counter.js'; + +const AdminsPreact = () => { + const list = useStore(admins); + const count = useStore(counter); + + return ( + <> + <h1>Preact</h1> + <ul> + {list.map(user => <li key={user.name}>{JSON.stringify(user, null, 2)}</li>)} + </ul> + <div> + <h3>Counter</h3> + <p>{count}</p> + <button onClick={decreaseCounter}>-1</button> + <button onClick={increaseCounter}>+1</button> + </div> + </> + ); +} + +export default AdminsPreact
\ No newline at end of file |