router报错
来源:3-8 服务端问题解决mobx的warning以及增加title等SEO友好标签

Aicheng123
2019-04-09
Warning: Rendering <Context.Consumer.Consumer> is not supported and will be removed in a future major release. Did you mean to render <Context.Consumer> instead?
Error: Invariant failed: You should not use <Link> outside a <Router>
at invariant (/Users/aiancheng/Documents/react/ssr_react/node_modules/tiny-invariant/dist/tiny-invariant.cjs.js:13:11)
at Object.children (/Users/aiancheng/Documents/react/ssr_react/node_modules/react-router-dom/cjs/react-router-dom.js:190:18)
at recursive (/Users/aiancheng/Documents/react/ssr_react/node_modules/react-tree-walker/dist/react-tree-walker.js:129:41)
at /Users/aiancheng/Documents/react/ssr_react/node_modules/react-tree-walker/dist/react-tree-walker.js:153:26
at process._tickCallback (internal/process/next_tick.js:68:7)
如上问题为: 将3-8章节, 给webpack.config.server.js添加externals, 在dev-static.js修改module引入方法, 即变更为getModuleFromString方法, 然后变更相关方法获取module之后执行服务端代码,就会报上面的错误。 找了好久没找到原因, 还请老师帮忙看一下。
写回答
1回答
-
Jokcy
2019-04-10
这里的意思是你在<Router>外面使用了<Link>,<Router>就是React-Router提供的BrowserRouter组件,它里面有context。这里就需要你检查代码了,是否有这样的情况。
032019-08-14
相似问题