fix: add useCallback

This commit is contained in:
Derrick Hammer 2023-10-16 17:43:13 -04:00
parent ef3256c6f9
commit 0907b2948c
Signed by: pcfreak30
GPG Key ID: C997C339BE476FF2
1 changed files with 3 additions and 2 deletions

View File

@ -2,6 +2,7 @@ import {
createContext, createContext,
createRef, createRef,
forwardRef, forwardRef,
useCallback,
useContext, useContext,
useEffect, useEffect,
useState, useState,
@ -133,7 +134,7 @@ export function Navigator() {
const { isLoggedIn } = useAuth(); const { isLoggedIn } = useAuth();
const inputRef = createRef<HTMLInputElement>(); const inputRef = createRef<HTMLInputElement>();
const browse = () => { const browse = useCallback(() => {
let input = inputRef.current?.value.trim(); let input = inputRef.current?.value.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
@ -153,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);
} }
}; }, [inputRef, setUrl]);
const NavInput = forwardRef((props: any, ref) => ( const NavInput = forwardRef((props: any, ref) => (
<Input ref={ref} {...props}></Input> <Input ref={ref} {...props}></Input>