But how to use Statera in React components?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import { statera } from 'statera';
// Create shared state
const useCounter = statera(0);
// Use shared state in any component
function Counter() {
const [count, setCount] = useCounter();
// ... render and update logic
}
// No providers needed, works with SSR too!
function App() {
return (
<>
<Counter />
<Counter />
</>
);
}
Statera isn't here to replace or compete with other libraries, it's designed to provide a lightweight solution for everyday development. Syncing state across components has never been easier! Install Statera today and experience the magic for yourself.