GithubHelp home page GithubHelp logo

jarweb / wolverine-state Goto Github PK

View Code? Open in Web Editor NEW
2.0 2.0 0.0 2.84 MB

a lightweight react state management lib build with contex、hook and immer

TypeScript 100.00%
react immer state-management hook

wolverine-state's Introduction

intro

a lightweight react state management lib based on immer 、 react hook and context

quick start

yarn add @jarzzzi/wolverine-state

example

const initialState: StoreData = {
 count: 0,
 show: false
}

const store = createStore(initialState)

function Demo () {
 const { count } = useConnect<StoreData, Partial<StoreData>>((state) => {
   return { count: state.count }
 })

 const inc = () => {
   store.produce((state) => {
     state.count++
   })
  }

 const dec = () => {
  store.produce((state) => {
   state.count--
  })
 }

 return (
   <div>
    <div>{count}</div>
    <button onClick={inc}>inc</button>
    <button onClick={dec}>dec</button>
   </div>
  )
}

function App () {
 return (
   <Provider value={store}>
    <Demo />
    <Text />
   </Provider>
 )
}

wolverine-state's People

Stargazers

Roman avatar jarzzzi avatar

Watchers

James Cloos avatar jarzzzi avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.