Permalink
Branch: master
Find file Copy path
f3ef7f4 Sep 30, 2018
3 contributors

Users who have contributed to this file

@ryanflorence @pshrmn @mjackson
45 lines (29 sloc) 1.11 KB

<MemoryRouter>

A <Router> that keeps the history of your "URL" in memory (does not read or write to the address bar). Useful in tests and non-browser environments like React Native.

import { MemoryRouter } from 'react-router'

<MemoryRouter>
  <App/>
</MemoryRouter>

initialEntries: array

An array of locations in the history stack. These may be full-blown location objects with { pathname, search, hash, state } or simple string URLs.

<MemoryRouter
  initialEntries={["/one", "/two", { pathname: "/three" }]}
  initialIndex={1}
>
  <App />
</MemoryRouter>

initialIndex: number

The initial location's index in the array of initialEntries.

getUserConfirmation: func

A function to use to confirm navigation. You must use this option when using <MemoryRouter> directly with a <Prompt>.

keyLength: number

The length of location.key. Defaults to 6.

<MemoryRouter keyLength={12} />

children: node

A single child element to render.