1.0.3 • Published 5 months ago

create-external-store v1.0.3

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

create-external-store

This npm package provides easy-to-use and heighly performant state manager

Installation

To install this package, run the following command:

npm install create-external-store

Usage

createExternalStore return a hook and a setter.

Use the hook in the component, use the setter anywhere. When you use the setter setNumber(2) components which use the hook useNumber() would be rerendered and display the new value.

const [useNumber, setNumber] = createExternalStore<number>(1)

setInterval(() => {
  setNumber(num => num + 1)
}, 1000)

function App() {
  const number = useNumber()
  const numberSquared = useNumber(num => num*num)
  return (
    <>
      <div>Number {number}</div>
      <div>Number squared {numberSquared}</div>
    </dib>
  )
}

export default App

License

This package is licensed under the MIT License. See the LICENSE file for more information.

1.0.3

5 months ago

1.0.2

5 months ago

1.0.1

5 months ago

1.0.0

5 months ago