Skip to content

Instantly share code, notes, and snippets.

Embed
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