From 8c906db3c5de463f26959a9fbe26ad6fb3e8633b Mon Sep 17 00:00:00 2001 From: Mike Fix Date: Fri, 25 Oct 2019 15:29:30 -0700 Subject: [PATCH] clean up Carbon --- components/Carbon.js | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/components/Carbon.js b/components/Carbon.js index 8073ba8..cff7afe 100644 --- a/components/Carbon.js +++ b/components/Carbon.js @@ -371,10 +371,7 @@ function useHighlightLoader() { React.useEffect(() => { if (!highLightsLoaded) { import('../lib/highlight-languages') - .then(res => { - // console.log(res.default) - res.default.map(config => hljs.registerLanguage(config[0], config[1])) - }) + .then(res => res.default.map(config => hljs.registerLanguage(config[0], config[1]))) .then(() => { highLightsLoaded = true }) @@ -442,8 +439,12 @@ function useSelectedLines(props, editorRef) { }, [state.selected, props.children, props.config, editorRef]) React.useEffect(() => { - let selectedLines = props.config.selectedLines || [] - dispatch({ type: 'MULTILINE', selectedLines }) + if (props.config.selectedLines) { + dispatch({ + type: 'MULTILINE', + selectedLines: props.config.selectedLines + }) + } }, [props.config.selectedLines]) return React.useCallback(function onGutterClick(editor, lineNumber, gutter, e) { @@ -453,14 +454,14 @@ function useSelectedLines(props, editorRef) { }, []) } -function useShowInvisibleLoader() { +function useShowInvisiblesLoader() { React.useEffect(() => void require('cm-show-invisibles'), []) } function CarbonContainer(props, ref) { useModeLoader() useHighlightLoader() - useShowInvisibleLoader() + useShowInvisiblesLoader() const editorRef = React.createRef() const onGutterClick = useSelectedLines(props, editorRef)