0.0.1 • Published 6 years ago
@evilfactory/global-state v0.0.1
@evilfactory/global-state
⚛️ Simple State Management from react to react powered by React Hook.
Install
$ yarn add -E @evilfactory/global-state$ npm i @evilfactory/global-state Features
- Zero configuration ✅.
- React hooks based API ✅.
- React Native supported ✅.
- Global State & shareable ✅.
- Redux Dev Tools supported 🙏.
API
Table of Contents
StateProvider
as Wrapper of your React Application.
Parameters
propsObjectprops.reducerprops.initialStateprops.children
Properties
reducerFunction | useReducerinitialStateObjectchildrenElement | createElement
Examples
Example Use of <StateProvider/>.
import React, {useReducer} from 'react'
import App from './you-app.js'
import {StateProvider} from 'evilfactorylabs/global-state'
const initialState = { todo: [] }
const reducer = useReducer(state, action)
ReactDOM.render(
<StateProvider reducer={reducer} initialState={initialState}>
<App/>
</StateProvider>
, document.getElementById('root'))useGlobalState
Parameters
Examples
import {useGlobalState} from '@evilfactorylabs/global-state'
...
const createTodo = (state, action, todo) => {
return action({
type: 'ADD_TODO',
data: todo,
})
}
const [,addTodo] = useGlobalState(createTodo)
addTodo({title: 'New Task'})
...0.0.1
6 years ago