skip to Main Content

Reactjs – React's context and input field duplicating string characters

import React, { createContext, useContext, useState } from "react"; export const ProductSearchTermContext = createContext(["", undefined]); function ProductSearchTermContextProvider() { const [searchTerm, setSearchTerm] = useState(""); function SetSearchTerm(term: string) { setSearchTerm((oldState) => oldState + term); } return ( <ProductSearchTermContext.Provider value={[searchTerm, SetSearchTerm]}> {children} </ProductSearchTermContext.Provider>…

VIEW QUESTION
Back To Top
Search