effector-react
TypeScript icon, indicating that this package has built-in type declarations

23.2.0 • 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 {useUnit} from 'effector-react'

const inputText = createEvent()

const $text = createStore('').on(inputText, (_, text) => text)

const $size = $text.map(text => text.length)

const Form = () => {
  const {text, size} = useUnit({
    text: $text,
    size: $size,
  })
  const handleTextChange = useUnit(inputText)

  return (
    <form>
      <input
        type="text"
        onChange={e => handleTextChange(e.currentTarget.value)}
        value={text}
      />
      <p>Length: {size}</p>
    </form>
  )
}

Try it

useUnit in docs Units in docs createStore in docs createEvent in docs

/effector-react/

    Package Sidebar

    Install

    npm i effector-react

    Homepage

    effector.dev

    Weekly Downloads

    28,204

    Version

    23.2.0

    License

    MIT

    Unpacked Size

    330 kB

    Total Files

    21

    Last publish

    Collaborators

    • drevoed
    • drelliot
    • sergeysova
    • lobatik
    • zero_bias
    • goodmind