@baiyezi/react

React tools

Usage no npm install needed!

<script type="module">
  import baiyeziReact from 'https://cdn.skypack.dev/@baiyezi/react';
</script>

README

react

Baiyezi react tools.

Installation

npm

$ npm install @baiyezi/react

yarn

$ yarn add @baiyezi/react

How to use

makeStore

import { makeStore } from '@baiyezi/react'

const { Provider, Consumer, useStore } = makeStore(0)

const Counter = () => {
  const [count] = useStore()
  return <span>{count}</span>
}

const Button = () => {
  const [, setCount] = useStore()
  return <button onClick={() => setCount(2)}>change count</button>
}

const App = () => {
  return (
    <Provider>
      <Counter />
      <Button />
    </Provider>
  )
}