Created
February 7, 2019 03:31
-
-
Save terrierscript/7b6363458c25f3bba35d77a034d61b6e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// https://github.com/terrierscript/dartystrap/blob/2b5c0a2fc7bb0060b2290664384303bab802d94f/src/app/compiler/CompileModeCheckbox.tsx#L21-L37 | |
const useCompileModeCheckboxState = () => { | |
const [compilerMode, setCompilerMode] = useState(CompilerMode.WORKER) | |
const handleUseWorker = useCallback( | |
(e) => { | |
const mode = e.target.checked ? CompilerMode.WORKER : CompilerMode.ASYNC | |
setCompilerMode(mode) | |
}, | |
[setCompilerMode] | |
) | |
const isWorker = useMemo(() => { | |
return compilerMode === CompilerMode.WORKER | |
}, [compilerMode]) | |
return { | |
isWorker, | |
handleUseWorker | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment