9 lines
276 B
JavaScript
9 lines
276 B
JavaScript
import { useReducer } from 'react';
|
|
var toggleReducer = function (state, nextValue) {
|
|
return typeof nextValue === 'boolean' ? nextValue : !state;
|
|
};
|
|
var useToggle = function (initialValue) {
|
|
return useReducer(toggleReducer, initialValue);
|
|
};
|
|
export default useToggle;
|