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

0.0.1 • Public • Published

Create React State

Install

pnpm add create-react-state

Create a useState

You can create a "useState" outside React components

import { createState } from 'create-react-state'

export const useCount = createState(0)

Use in any React Component

import useCount in any component

import './App.css'
import { createState } from 'create-react-state'

export const useCount = createState(0)

export default function App() {
  const [count, setCount] = useCount()

  return (
    <button onClick={() => setCount((count) => count + 1)}>
      count is {count}
    </button>
  )
}

Readme

Keywords

Package Sidebar

Install

npm i create-react-state

Weekly Downloads

2

Version

0.0.1

License

MIT

Unpacked Size

2.31 kB

Total Files

4

Last publish

Collaborators

  • glitch-txs