fix(chatComponent): add isBuilt dependency to useEffect hook to avoid stale closure and improve performance
This commit is contained in:
parent
b476d0dd74
commit
cad24f1f88
1 changed files with 2 additions and 2 deletions
|
|
@ -16,7 +16,7 @@ export default function Chat({ flow }: ChatType) {
|
|||
const handleKeyDown = (event: KeyboardEvent) => {
|
||||
if (
|
||||
(event.key === "K" || event.key === "k") &&
|
||||
(event.metaKey || event.ctrlKey)
|
||||
(event.metaKey || event.ctrlKey) && isBuilt
|
||||
) {
|
||||
event.preventDefault();
|
||||
setOpen((oldState) => !oldState);
|
||||
|
|
@ -26,7 +26,7 @@ export default function Chat({ flow }: ChatType) {
|
|||
return () => {
|
||||
document.removeEventListener("keydown", handleKeyDown);
|
||||
};
|
||||
}, []);
|
||||
}, [isBuilt]);
|
||||
|
||||
useEffect(() => {
|
||||
// Define an async function within the useEffect hook
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue