1.0.1 • Published 5 years ago
use-local-state v1.0.1
use-local-state
Allow handle complex state in React using userReducer
Install
npm install --save use-local-state
Usage
import React, { Component } from 'react'
import { useLocalState } from 'use-local-state'
const Example = () => {
const [state, dispatchState] = useLocalState({
name: "Josh",
lastName: 'Kurl'
})
return (
<div>
<button onClick={() => dispatchState({name: 'name', value: 'Reich'})}>Change</button>
<button onClick={() => dispatchState([{name: 'name', value: 'Griin'}, {name: 'lastName', value: 'Poll'}])}>Change</button>
{state.name}
{state.lastName}
</div>
)
}
License
MIT © yanielbf
This hook is created using create-react-hook.