React routing filters
Package allows you to share filters (or other serializable data) across url's,
even if you using HashRouter
. Urls are copyable across application :)
E.g.: if you want to pass object like below in application url
name: 'Dave' surname: 'Wo'
with this library you can achieve something like this:
localhost:3000/#/users/?name=Dave&surname=Wo
API
Context provides api described below:
Usage
FiltersProvider
Provides context which looks like this:
Warning
if you want set array in filters:
;
remember that values passed in array can not contains comas. It's because filters are parsed according to URL search string rules which specify that comas are separators for one-to-many values
Example
;;; { const setFilters = ; const handleClick = ; return <button onClick=handleClick> Set random filter </button>} { const filters = ; return <pre>JSON</pre>;} { return <FiltersProvider> <div> <FiltersButton /> <LogFilters /> </div> </FiltersProvider> ;} const rootElement = document;ReactDOM;