React Effector почему count не увеличивается и не передается в компоненте?
1234567891011121314151617
// 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
123456789101112131415
// 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 }
По дате
По рейтингу
1
const count = useStore(counter).count;