Skip to content

Custom Query String Parsing docs in V2 upgrade guide #2842

@npbee

Description

@npbee

I may have run into a small documentation error regarding custom query string parsing in V2:

https://github.com/rackt/react-router/blob/master/upgrade-guides/v2.0.0.md#custom-query-string-parsing

I think instead of what's listed there for V2 we actually need to use a custom history like in https://github.com/rackt/react-router/blob/master/upgrade-guides/v2.0.0.md#using-custom-histories.

So, changing this:

// v1.x
<Router
  parseQueryString={parse}
  stringifyQueryString={stringify}
/>

// v2.0.0
import { useRouterHistory, browserHistory } from 'react-router'

const createAppHistory = useRouterHistory(browserHistory)

const appHistory = createAppHistory({
  parseQueryString: parse,
  stringifyQueryString: stringify
})

<Router history={appHistory}/>

to

// v1.x
<Router
  parseQueryString={parse}
  stringifyQueryString={stringify}
/>

// v2.0.0
import { useRouterHistory } from 'react-router'
import createBrowserHistory from 'history/lib/createBrowserHistory'

const createAppHistory = useRouterHistory(createBrowserHistory)

const appHistory = createAppHistory({
  parseQueryString: parse,
  stringifyQueryString: stringify
})

<Router history={appHistory}/>

I'm happy to make a PR with the changes, but I just wanted to make sure I'm not off base here.

Thanks for all of your work!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions