G
G
Garri_Klim2021-11-01 16:15:18
React
Garri_Klim, 2021-11-01 16:15:18

In my search bar, instead of the “+” sign, these symbols “% 2b” are displayed. How to solve it? Can you write a function?

const SearchForm = () => {
    const [isSearchOpen, setSearchOpen] = useState(false),
        formRef = useRef(null);
    useClickOutside(formRef, () => setSearchOpen(false));
    const [inputText, setInputText] = useState("");
    const handleSubmit = e => {
        if (inputText.length >= 150) {
            alert('Maximum length 150 characters ')
            e.preventDefault();
        }
    };


    return (
        <form
            ref={formRef}
            className={cn("search-form", {
                "search-form--focus": isSearchOpen,
            })}
            onClick={() => setSearchOpen(true)}
            onKeyPress={() => setSearchOpen(true)}
            action="/search"
            // eslint-disable-next-line
            role="searchbox"
            onSubmit={handleSubmit}
        >
            
            <input
                value={inputText}
                onChange={e => setInputText(e.target.value)}
                className="search-form__input"
                name="filter"
                type="text"
            
            />
          
            
            <button
                className="search-form__button"
                type="submit"
                aria-label="Header search button"
            />
        </form>
    );
};


617fe85db7a25067240780.jpeg

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
Nikolay Matyushkin, 2021-11-01
@Devilz_1

decodeURIComponent(/*any string*/)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question