Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

add query parameter to url react router v6

const Users = () => {
  const navigate = useNavigate();
  const goToPosts = () =>
    navigate({
      pathname: '/posts',
      search: '?sort=date&order=newest',
    });

  return (
    <div>
      Users
      <button onClick={goToPosts}>Go to Posts</button>
    </div>
  );
};
Source by ultimatecourses.com #
 
PREVIOUS NEXT
Tagged: #add #query #parameter #url #react #router
ADD COMMENT
Topic
Name
5+9 =