Skip to content

Instantly share code, notes, and snippets.

@yurkimus
Last active September 2, 2023 14:27
Show Gist options
  • Save yurkimus/de9e465adaf45fa907dd1d1b9759b6fc to your computer and use it in GitHub Desktop.
Save yurkimus/de9e465adaf45fa907dd1d1b9759b6fc to your computer and use it in GitHub Desktop.
Reactive URLSearchParams with ramda and react-router
const [searchParams, setSearchParams] = useSearchParams({ [searchParam]: defaultValue, })
useEffect(() => {
setSearchParams(
tap(
when(
compose(anyPass([isEmpty, isNil]), invokeGet(tabSearchParam)),
invokeSet(searchParam, defaultValue)
)
)
)
}, [searchParams])
const searchParam = 'test'
const defaultValue = 'value'
const invokeGet = invoker(1, 'get')
const invokeSet = invoker(2, 'set')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment