UNPKG

@boomerang-io/carbon-addons-boomerang-react

Version:
18 lines (15 loc) 528 B
import { useState, useCallback } from 'react'; /* IBM Confidential 694970X, 69497O0 © Copyright IBM Corp. 2022, 2024 */ // https://github.com/streamich/react-use/blob/master/src/useSetState.ts const useSetState = (initialState = {}) => { const [state, set] = useState(initialState); const setState = useCallback((patch) => { set((prevState) => Object.assign({}, prevState, patch instanceof Function ? patch(prevState) : patch)); }, []); return [state, setState]; }; export { useSetState as default };