I've just dropped React Router 2.0-rc4 into a project. Within the tests I changed where createMemoryHistory is pulled in from, previously it was coming from import createMemoryHistory from 'history/lib/createMemoryHistory'; and as of the React Router 2.0-rc4 drop in it's now import { createMemoryHistory } from 'react-router';.
When I run the tests I'm getting the following error when running my tests
TypeError: (0 , _reactRouter.createMemoryHistory) is not a function.
Within the tests I'm using createMemoryHistory as follows:
import { createMemoryHistory } from 'react-router';
...
const history = createMemoryHistory('/');
const rendered = renderToString(
<Root history={history} />
);
The docs don't show an example of importing createMemoryHistory so I assume I'm importing it incorrectly and it isn't a subtle bug.
It's been fixed on master.
Thanks for the heads up @taion
I'm getting error in 1.0.3 when using Webpack to do a target: node bundle.
I also tried import { createMemoryHistory } from 'history/lib/createMemoryHistory' to no avail.
When logging to the console, createMemoryHistory is showing as undefined.
It's a default export. You don't need to import the individual function: import createMemoryHistory from 'history/lib/createMemoryHistory'
Thanks! This fixed my issue.
Uncaught TypeError: (0 , _reactRouter.createMemoryHistory) is not a function
import { createMemoryHistory } from 'react-router';
import { createMemoryHistory } from 'react-router-dom';
Hi I'm still getting this error, tried both above. My react-router and react-router-dom versions are both 4.1.1
@leongaban v4 no longer re-exports history objects. Instead, just import directly from history.
import { createMemoryHistory } from 'history';
Most helpful comment
@leongaban v4 no longer re-exports history objects. Instead, just import directly from
history.