refactor: change the approach of onSubmit prop function passing

instead of arrow function we pass just queryOnsubmit and retrieve the event from the function itself
This commit is contained in:
kKaskak 2024-01-03 15:58:57 +02:00
parent 19207937f1
commit b7e77417b4

View file

@ -59,8 +59,9 @@ const SearchBar = React.memo(({ className, query, active }) => {
}
}, [createTorrentFromMagnet]);
const queryInputOnSubmit = React.useCallback((searchValue, event) => {
const queryInputOnSubmit = React.useCallback((event) => {
event.preventDefault();
const searchValue = `/search?search=${event.target.value}`;
setCurrentQuery(searchValue);
if (searchInputRef.current && searchValue) {
window.location.hash = searchValue;
@ -107,7 +108,7 @@ const SearchBar = React.memo(({ className, query, active }) => {
defaultValue={query}
tabIndex={-1}
onChange={queryInputOnChange}
onSubmit={(e) => queryInputOnSubmit(`/search?search=${e.target.value}`, e)}
onSubmit={queryInputOnSubmit}
onClick={openHistory}
/>
: