url parameters - Convert search string to query object (after switching to react-router v4) -
after switching react-router 4.0 dumbly wasted way time trying figure out how , set location.search string regular query object.
even after realizing they're not handling query params anymore (parse query parameters in react router v4) , turning urlsearchparams couldn't remember how extract object iterator. answer below. hope helps someone.
at least here's pretty short way lodash:
const getquery = () => { let qp = new urlsearchparams(location.search) _.frompairs([...qp.entries()]) } oh, , now, on submitting see: how parse query string in react-router v4, answer gets whole object.
Comments
Post a Comment