Skip to content

How to update search params from input field #8646

Closed Answered by ondrejvelisek
pineshmenat asked this question in Q&A
Discussion options

You must be logged in to vote

Something like this does not work? (not tested)

import { useSearchParams } from "react-router-dom";

function App() {
  const [searchParams, setSearchParams] = useSearchParams();

  function onChange(event) {
    setSearchParams(event.target.value);
  }

  return (
      <input value={searchParams} onChange={onChange}/>
  );
}

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@pineshmenat
Comment options

Answer selected by pineshmenat
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants