4.0.0-alpha.4
Following - https://react-router.now.sh/ServerRouter
Following - https://react-router.now.sh/ServerRouter
static markup being displayed in browser
~/react-app/node_modules/invariant/invariant.js:49
throw error;
^
Invariant Violation: Browser history needs a DOM
at invariant (~/react-app/node_modules/invariant/invariant.js:42:15)
at createBrowserHistory (~/react-app/node_modules/history/createBrowserHistory.js:51:102)
at History.setupHistory (~/react-app/node_modules/react-history/History.js:43:20)
at History.componentWillMount (~/react-app/node_modules/react-history/History.js:50:10)
at ~/react-app/node_modules/react/lib/ReactCompositeComponent.js:347:23
at measureLifeCyclePerf (~/react-app/node_modules/react/lib/ReactCompositeComponent.js:74:12)
at ReactCompositeComponentWrapper.performInitialMount (~/react-app/node_modules/react/lib/ReactCompositeComponent.js:346:9)
at ReactCompositeComponentWrapper.mountComponent (~/react-app/node_modules/react/lib/ReactCompositeComponent.js:257:21)
at Object.mountComponent (~/react-app/node_modules/react/lib/ReactReconciler.js:47:35)
at ReactCompositeComponentWrapper.performInitialMount (~/react-app/node_modules/react/lib/ReactCompositeComponent.js:370:34)
ServerRouter
replaces BrowserRouter
. I'm guessing your <App>
has a <BrowserRouter>
inside it. On the server wrap your app in <ServerRouter>
, in the client wrap it in <BrowserRouter>
.
ahh, I see, I have been following the example too blindly, side effect of copy paste. Didn't realize Router
is referring to BrowserRouter
import Router from 'react-router/BrowserRouter';
Thanks!
It's called <StaticRouter>
now, not <ServerRouter>
.
Most helpful comment
ServerRouter
replacesBrowserRouter
. I'm guessing your<App>
has a<BrowserRouter>
inside it. On the server wrap your app in<ServerRouter>
, in the client wrap it in<BrowserRouter>
.