Skip to content

Instantly share code, notes, and snippets.

Created November 7, 2019 15:12
What would you like to do?
import { useState, useCallback } from 'react'
import produce from 'immer'
const useImmerState = initialState => {
const [state, setState] = useState(initialState)
const setImmerState = useCallback(setter => setState(produce(setter)), [])
return [state, setImmerState]
export default useImmerState
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment