fix: remove callback caching

This commit is contained in:
Derrick Hammer 2023-10-16 18:37:10 -04:00
parent 88c7bf5ec5
commit e7c40cdf32
Signed by: pcfreak30
GPG Key ID: C997C339BE476FF2
1 changed files with 3 additions and 6 deletions

View File

@ -134,7 +134,7 @@ export function Navigator() {
const { isLoggedIn } = useAuth(); const { isLoggedIn } = useAuth();
const [inputValue, setInputValue] = useState(contextUrl); // Local state for the input value const [inputValue, setInputValue] = useState(contextUrl); // Local state for the input value
const browse = useCallback(() => { const browse = () => {
let input = inputValue.trim(); let input = inputValue.trim();
// If the input doesn't contain a protocol, assume it's http // If the input doesn't contain a protocol, assume it's http
@ -154,7 +154,7 @@ export function Navigator() {
// Handle invalid URLs here, if needed // Handle invalid URLs here, if needed
console.error("Invalid URL:", e); console.error("Invalid URL:", e);
} }
}, [contextUrl, setUrl]); };
useEffect(() => { useEffect(() => {
setInputValue(contextUrl); // Update local state when context's url changes setInputValue(contextUrl); // Update local state when context's url changes
@ -170,10 +170,7 @@ export function Navigator() {
<> <>
<NavInput <NavInput
value={inputValue} value={inputValue}
onChange={(e: any) => { onChange={(e: any) => setInputValue(e.target.value)}
debugger;
setInputValue(e.target.value);
}}
disabled={!isLoggedIn} disabled={!isLoggedIn}
/> />
<Button onClick={browse} disabled={!isLoggedIn}> <Button onClick={browse} disabled={!isLoggedIn}>