mirror of
https://github.com/csunny/DB-GPT.git
synced 2025-09-28 21:12:13 +00:00
18 lines
298 B
TypeScript
18 lines
298 B
TypeScript
import { useReducer } from 'react';
|
|
|
|
const useStateReducer = <T>(initialState: T) => {
|
|
const methods = useReducer(
|
|
(state: T, newState: Partial<T>) => ({
|
|
...state,
|
|
...newState,
|
|
}),
|
|
{
|
|
...initialState,
|
|
}
|
|
);
|
|
|
|
return methods;
|
|
};
|
|
|
|
export default useStateReducer;
|