0
Fork 0
mirror of https://github.com/withastro/astro.git synced 2025-01-27 22:19:04 -05:00
astro/examples/with-nanostores/src/components/AdminsReact.jsx

30 lines
707 B
React
Raw Normal View History

2021-06-24 22:40:29 +00:00
import React from 'react';
import { useStore } from '@nanostores/react';
2021-06-24 22:40:29 +00:00
import { admins } from '../store/admins.js';
import { counter, increaseCounter, decreaseCounter } from '../store/counter.js';
const AdminsReact = () => {
const list = useStore(admins);
const count = useStore(counter);
return (
<>
<h1>React</h1>
<ul>
2021-06-24 22:40:29 +00:00
{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>
<br />
</>
);
2021-06-24 22:40:29 +00:00
};
2021-06-24 22:40:29 +00:00
export default AdminsReact;