Convert vscodeMessageHandler to use useCallback
This commit is contained in:
@@ -145,13 +145,16 @@ export function ResultTables(props: ResultTablesProps) {
|
|||||||
}
|
}
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const vscodeMessageHandler = (evt: MessageEvent): void => {
|
const vscodeMessageHandler = useCallback(
|
||||||
// sanitize origin
|
(evt: MessageEvent): void => {
|
||||||
const origin = evt.origin.replace(/\n|\r/g, "");
|
// sanitize origin
|
||||||
evt.origin === window.origin
|
const origin = evt.origin.replace(/\n|\r/g, "");
|
||||||
? handleMessage(evt.data as IntoResultsViewMsg)
|
evt.origin === window.origin
|
||||||
: console.error(`Invalid event origin ${origin}`);
|
? handleMessage(evt.data as IntoResultsViewMsg)
|
||||||
};
|
: console.error(`Invalid event origin ${origin}`);
|
||||||
|
},
|
||||||
|
[handleMessage],
|
||||||
|
);
|
||||||
|
|
||||||
// TODO: Duplicated from results.tsx consider a way to
|
// TODO: Duplicated from results.tsx consider a way to
|
||||||
// avoid this duplication
|
// avoid this duplication
|
||||||
|
|||||||
Reference in New Issue
Block a user