Package Exports
- effector-react
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (effector-react) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Effector-react
React bindings for effector
Installation
npm install --save effector effector-reactOr using yarn
yarn add effector effector-reactUsage
import {createStore, createStoreObject, createEvent} from 'effector'
import {createStoreConsumer} from 'effector-react'
const inputText = createEvent('input text')
const text = createStore('').on(inputText, (state, payload) => payload)
const length = createStore(0).on(inputText, (state, payload) => payload.length)
const store = createStoreObject({
text,
length,
})
const FormStore = createStoreConsumer(store)
const Form = () => (
<FormStore>
{state => (
<form>
<input
type="text"
onChange={e => inputText(e.currentTarget.value)}
value={state.text}
/>
<p>Length: {state.length}</p>
</form>
)}
</FormStore>
)