1.0.2 • Published 2 years ago

react-hook-simple-state v1.0.2

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

Features

  • 😎 Easy!!!
  • 😎 Support hook
  • 😎 Better performance optimization

Install

npm i react-hook-simple-state

# yarn add react-hook-simple-state
# pnpm add react-hook-simple-state

Usage

import { useStore } from "react-hook-simple-state";



// for hook component
function App() {
  const [store,setStore] = useStore('countStoreKey',{count:0});
  return (
    <>
      {count}
      <button onClick={() => setStore({count: store.count + 1})}>+</button>
      <DemoCompoment />
    </>
  );
}

function DemoCompoment() {
  const [store,setStore] = useStore('countStoreKey',{count:0});
    return (
    <>
      {count}
    </>
  );
}

Basic API

react-hook-simple-state requires the version of React v >= 16.8

APIDescription
useStoreCreate a store container for state
1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago