From d43c5766cf0d4de4cc38091b54281d1c0f5faad1 Mon Sep 17 00:00:00 2001 From: Mike Fix Date: Sat, 10 Aug 2019 11:11:29 -0700 Subject: [PATCH] use useCallback for useGutterClickHandler --- components/Carbon.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/Carbon.js b/components/Carbon.js index bc5a049..11f463a 100644 --- a/components/Carbon.js +++ b/components/Carbon.js @@ -322,7 +322,7 @@ function useGutterClickHandler(props) { } }, [state.selected, props.children, props.config]) - return function onGutterClick(editor, lineNumber, gutter, e) { + return React.useCallback(function onGutterClick(editor, lineNumber, gutter, e) { editorRef.current = editor const numLines = editor.display.view.length @@ -331,7 +331,7 @@ function useGutterClickHandler(props) { } else { dispatch({ type: 'LINE', lineNumber, numLines }) } - } + }, []) } function CarbonContainer(props, ref) {