2021-12-13 15:37:06 -03:00
|
|
|
import * as React from 'react';
|
2021-11-22 00:31:42 +07:00
|
|
|
import { useStore } from '@nanostores/react';
|
2021-06-24 19:39:17 -03:00
|
|
|
|
2021-06-24 22:40:29 +00:00
|
|
|
import { admins } from '../store/admins.js';
|
2021-06-24 19:39:17 -03:00
|
|
|
import { counter, increaseCounter, decreaseCounter } from '../store/counter.js';
|
|
|
|
|
|
|
|
const AdminsReact = () => {
|
|
|
|
const list = useStore(admins);
|
|
|
|
const count = useStore(counter);
|
2021-12-13 18:37:58 +00:00
|
|
|
|
2021-06-24 19:39:17 -03:00
|
|
|
return (
|
|
|
|
<>
|
|
|
|
<h1>React</h1>
|
|
|
|
<ul>
|
2021-12-13 15:37:06 -03:00
|
|
|
{list.map((admin) => (
|
|
|
|
<li key={admin.id}>{JSON.stringify(admin, null, 2)}</li>
|
2021-06-24 22:40:29 +00:00
|
|
|
))}
|
2021-06-24 19:39:17 -03:00
|
|
|
</ul>
|
|
|
|
<div>
|
|
|
|
<h3>Counter</h3>
|
2021-12-13 15:37:06 -03:00
|
|
|
<p>{count.value}</p>
|
2021-06-24 19:39:17 -03:00
|
|
|
<button onClick={decreaseCounter}>-1</button>
|
|
|
|
<button onClick={increaseCounter}>+1</button>
|
|
|
|
</div>
|
|
|
|
<br />
|
|
|
|
</>
|
|
|
|
);
|
2021-06-24 22:40:29 +00:00
|
|
|
};
|
2021-06-24 19:39:17 -03:00
|
|
|
|
2021-06-24 22:40:29 +00:00
|
|
|
export default AdminsReact;
|