diff --git a/src/App.jsx b/src/App.jsx index 5d207d5..a5be56b 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -1,4 +1,4 @@ -import { useEffect, useRef } from 'react' +import { useEffect, useRef, useState } from 'react' import { useDispatch } from 'react-redux' import { setQuery } from './app/searchSlice' import { setShowName } from './app/displaySlice' @@ -9,9 +9,13 @@ function App() { const inputSearch = useRef() const checkShowName = useRef() const dispatch = useDispatch() + const [currentQuery, setCurrentQuery] = useState("") function queryOnChange () { - dispatch(setQuery(inputSearch.current.value)) + let query = inputSearch.current.value + query = query.replace(/[^a-zA-Z0-9\- ]/, "") + setCurrentQuery(query) + dispatch(setQuery(query)) } function showNameOnChange () { @@ -25,7 +29,7 @@ function App() { return ( <>