1.2.0 • Published 10 months ago

react-router-toolkit v1.2.0

Weekly downloads
-
License
MIT
Repository
github
Last release
10 months ago

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;
}
1.2.0

10 months ago

1.1.3

10 months ago

1.1.2

10 months ago

1.1.1

11 months ago

1.1.0

11 months ago

1.0.0

1 year ago

0.0.2

1 year ago

0.0.1

1 year ago