fuck-redux
TypeScript icon, indicating that this package has built-in type declarations

0.0.7 • Public • Published

f-redux

the hooks revolution has just started

Usage

npm i fuck-redux
import makeHook, { Store } from 'fuck-redux'

const initialState = {
    counter: 0,
}

const actions = (store: Store<typeof initialState>) => ({
    addToCounter: (amount) => {
        const newCounterValue = store.state.counter + amount
        store.setState({ counter: newCounterValue })
    },
})

const useSharedState = makeHook(initialState, actions)

const App = () => {
    const [globalState, globalActions] = useSharedState()
    return (
        <div>
            <p>
                counter:
                {globalState.counter}
            </p>
            <button type='button' onClick={() => globalActions.addToCounter(1)}>
                +1 to global
            </button>
        </div>
    )
}

Readme

Keywords

none

Package Sidebar

Install

npm i fuck-redux

Weekly Downloads

0

Version

0.0.7

License

ISC

Unpacked Size

5.39 kB

Total Files

6

Last publish

Collaborators

  • xmorse