effector-react

React bindings for effector

Usage no npm install needed!

<script type="module">
  import effectorReact from 'https://cdn.skypack.dev/effector-react';
</script>

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, (_, text) => text)
  
const $size = createStore(0)
  .on(inputText, (_, text) => text.length)

const $form = combine({
  text: $text,
  size: $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