0.23.0 • Published 6 months ago

effector-solid v0.23.0

Weekly downloads
-
License
MIT
Repository
github
Last release
6 months ago

effector-solid

SolidJS bindings for effector

Installation

npm install --save effector effector-solid

Or using yarn

yarn add effector effector-solid

Or using pnpm

pnpm add effector effector-solid

Usage

import {createStore, combine, createEvent} from 'effector'

import {useUnit} from 'effector-solid'

const inputText = createEvent()

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

const $size = createStore(0).on(inputText, (_, text) => text.length)

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

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