From a97058f04e03bbf0c59cfabc0381c277273936bc Mon Sep 17 00:00:00 2001 From: Eric Giovanola Date: Sat, 25 Feb 2023 22:41:36 -0800 Subject: [PATCH] Update Manager --- src/core/TypeaheadManager.tsx | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/core/TypeaheadManager.tsx b/src/core/TypeaheadManager.tsx index 61cb6008..f6544363 100644 --- a/src/core/TypeaheadManager.tsx +++ b/src/core/TypeaheadManager.tsx @@ -1,5 +1,4 @@ -import React, { KeyboardEvent, useEffect } from 'react'; -import usePrevious from '@restart/hooks/usePrevious'; +import React, { KeyboardEvent, useEffect, useRef } from 'react'; import { TypeaheadContext, TypeaheadContextType } from './Context'; import { @@ -69,7 +68,6 @@ const TypeaheadManager = (props: TypeaheadManagerProps) => { selectHint, } = props; - const prevProps = usePrevious(props); const hintText = getHintText(props); useEffect(() => { @@ -79,11 +77,14 @@ const TypeaheadManager = (props: TypeaheadManagerProps) => { } }); + const isInitialRender = useRef(true); useEffect(() => { - if (prevProps && prevProps.isMenuShown !== isMenuShown) { - onMenuToggle(isMenuShown); + if (isInitialRender.current) { + isInitialRender.current = false; + return; } - }); + onMenuToggle(isMenuShown); + }, [isMenuShown, onMenuToggle]); const handleKeyDown = (e: KeyboardEvent) => { onKeyDown(e);