@stembord/state-react

connect react components with state stores

Usage no npm install needed!

<script type="module">
  import stembordStateReact from 'https://cdn.skypack.dev/@stembord/state-react';
</script>

README

ts-state-react

connect react components with state stores

Hooks

export const state = new State(INITIAL_STATE);
// Provider and Consumer from Context created with React.createContext
// useState is hook used to map state to props
export const { useState, Provider, Consumer, Context } = createHook(
  state.getState()
);
$ npm run todolist-hooks

Connect

export const state = new State(INITIAL_STATE);
// Provider and Consumer from Context created with React.createContext
// connect is used to map state to props
export const { Context, Provider, Consumer, connect } = createContext(
  state.getState()
);
$ npm run todolist-connect