// App.jsx
import { counter, decrement, increment } from './init'
const App = () => {
const count = counter.getState().count;
console.log(count)
return (
<div>
<h1>{count}</h1>
<button onClick={increment}>+</button>
<button onClick={decrement}>-</button>
</div>
)
}
export default App
// init.js
import { createStore, createEvent, combine } from 'effector'
const increment = createEvent()
const decrement = createEvent()
const $count = createStore(0)
.on(increment, (state) => state + 1)
.on(decrement, (state) => state - 1)
const counter = combine({
count: $count,
})
export { counter, increment, decrement }