Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

instant search initial value

const getURLParam = (key = 's') => {
  const urlParams = new URLSearchParams(window.location.search);
  const param = urlParams.get(key);

  return param || '';
};

const App = () => {
// set initial value
const [query, setQuery] = useState(getURLParam());

return (
	<InstantSearch
          searchClient={searchClient}
          indexName="post"
          searchState={{ query }}
        >
          <SearchBox
            onChange={(e) => setQuery(e.target.value)}
          />
        {/* ... */}
     </InstantSearch>
)
}
Comment

PREVIOUS NEXT
Code Example
Javascript :: firebase check if key exists javascript 
Javascript :: switch case block scope 
Javascript :: hover inline css 
Javascript :: sharepoint javascript get last added item 
Javascript :: petru a retuna toate toate datele in java script 
Javascript :: javascript nested arrays stackoverflow 
Javascript :: descomponer un numero js 
Javascript :: this.$moment.tz.guess() not working mozilla 
Javascript :: how to set a custom error message to a form in angular 
Javascript :: asp.net mvc with ext js 
Javascript :: how to connect two model in mongoose 
Javascript :: one dimensional array in javascript 
Javascript :: how to change in website with node js 
Javascript :: javascript nested destructuring 
Javascript :: prepare webpack-ready 
Javascript :: how to make your own version of filter method 
Javascript :: a method that will do something to each of the values in the array 
Javascript :: input should reject non-alphabetical input reacj js 
Javascript :: class function constructor 
Javascript :: Print the third number from right 
Javascript :: Create Own Variable As "Constructor Function" 
Javascript :: javascript convert string to number with 2 decimal places 
Javascript :: volta node list 
Javascript :: Creatable Multiselect 
Javascript :: no display after adding vue router 
Javascript :: numberformat chakra 
Javascript :: pass prop through route 
Javascript :: hide Card Number Format 
Javascript :: javascript chicken 
Javascript :: jquery find include self 
ADD CONTENT
Topic
Content
Source link
Name
1+1 =