media-stream-player
Version:
Player built on top of media-stream-library
14 lines • 442 B
JavaScript
import { useState, useCallback } from 'react';
export const useSwitch = (initialValue = false) => {
const [value, setValue] = useState(initialValue);
const toggleValue = useCallback((state) => {
if (state !== undefined) {
setValue(state);
}
else {
setValue((oldValue) => !oldValue);
}
}, [setValue]);
return [value, toggleValue];
};
//# sourceMappingURL=useSwitch.js.map