react-router-toolkit
TypeScript icon, indicating that this package has built-in type declarations

1.2.0 • Public • Published

API

parseQueryString: queryString to queryMap
const queryString = 'name=zhangshan&age=18&height=180'
const queryString2 = '?name=zhangshan&age=18&height=180'

const queryMap = parseQueryString(queryString)
const queryMap2 = parseQueryString(queryString2)
toQueryString: queryMap to queryString
const queryMap = {
  name: 'zhangshan',
  age: 18,
  height: 180,
}

const queryString = toQueryString(queryMap)
useRouterQuery: quick get query and set query
interface IQueryMap {
  name: string;
  age: string;
  height: string;
  loves: ParsedUrlQuery;
}

const [routerRuery, setRouterQuery] = useRouterQuery<IQueryMap>();
const name = routerRuery.name;
const loves = routerRuery.loves;
// or
const [{ name, loves }, setRouterQuery] = useRouterQuery<IQueryMap>();

setRouterQuery((preState) => ({
  ...preState,
  name: "lisi",
}));

common interface

Dictionary
interface Dictionary<T> {
  [key: string]: T;
}
ParsedUrlQueryValue
type ParsedUrlQueryValue = string | string[];
ParsedUrlQuery
interface ParsedUrlQuery {
  [key: string]: ParsedUrlQueryValue;
}

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
1.2.018latest

Version History

VersionDownloads (Last 7 Days)Published
1.2.018
1.1.30
1.1.20
1.1.10
1.1.00
1.0.00
0.0.20
0.0.10

Package Sidebar

Install

npm i react-router-toolkit

Weekly Downloads

18

Version

1.2.0

License

MIT

Unpacked Size

6.51 kB

Total Files

12

Last publish

Collaborators

  • rookie-luochao