Miss any of our Open RFC calls?Watch the recordings here! »

effector-react

20.7.3 • Public • Published

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>
  )
}

Try it

useStore in docs createStore in docs combine in docs createEvent in docs

Install

npm i effector-react

DownloadsWeekly Downloads

5,360

Version

20.7.3

License

MIT

Unpacked Size

141 kB

Total Files

24

Last publish

Collaborators

  • avatar
  • avatar