// App.jsx import { counter, decrement, increment } from './init' const App = () => { const count = counter.getState().count; console.log(count) return ( {count} + - ) } 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 }
const count = useStore(counter).count;