Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

createSearchParams

// React Router v6:
// thin wrapper around 'new URLSearchParams(init)' which adds
// support for using objects with array values.
// Same internal fn 'useSearchParams' uses to create 'URLSearchParams'
import { createSearchParams, useNavigate } from 'react-router-dom'

const navigate = useNavigate();

navigate({
  pathname: 'listing',
  search: `?${createSearchParams({ foo: 'bar'}).toString()}`
})
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #createSearchParams
ADD COMMENT
Topic
Name
3+5 =