@sergeysova/effector-react
v22.0.1
Published
React bindings for effector
Downloads
1
Maintainers
Readme
effector-react
React bindings for effector
Installation
npm install --save effector effector-react
Or using yarn
yarn add effector effector-react
Usage
import {createStore, combine, createEvent} from 'effector'
import {useStore} from 'effector-react'
const inputText = createEvent()
const text = createStore('').on(inputText, (state, payload) => payload)
const size = createStore(0).on(inputText, (state, payload) => payload.length)
const form = combine({
text,
size,
})
const Form = () => {
const {text, size} = useStore(form)
return (
<form>
<input
type="text"
onChange={e => inputText(e.currentTarget.value)}
value={text}
/>
<p>Length: {size}</p>
</form>
)
}
useStore in docs createStore in docs combine in docs createEvent in docs