在默认 Piral 实例中调试我的 pilet 时出现此错误:
Uncaught Error: Invariant failed: You should not use <Link> outside a <Router>
奇怪的是下一个日志条目报告错误来自内部:Router
react_devtools_backend.js:2430 The above error occurred in the <Context.Consumer> component:
in Link
in Unknown
in Suspense (created by ErrorBoundary)
in ErrorBoundary
in Unknown (created by Menu)
in li (created by MenuItem)
in MenuItem
in Unknown (created by Menu)
in ul (created by MenuContainer)
in div (created by MenuContainer)
in div (created by MenuContainer)
in nav (created by MenuContainer)
in header (created by MenuContainer)
in MenuContainer
in Unknown (created by Menu)
in Menu (created by Layout)
in div (created by Layout)
in Layout
in Unknown (created by PiralContent)
in PiralContent (created by PiralView)
in Router (created by BrowserRouter)
in BrowserRouter
in Unknown (created by PiralView)
in PiralProvider (created by PiralView)
in PiralView (created by Piral)
in Piral
我的堆索引.jsx:
import { Link } from 'react-router-dom'
const App = () => 'My pilet'
export function setup(app) {
app.registerPage('/my-pilet', App)
app.registerMenu(() => <Link to="/my-pilet">My Pilet</Link>)
}
我的 Piral 实例使用由提供的样板,piral-cli
并且完全没有变化。它甚至有一个可以正常工作且没有错误的默认菜单项:
(“未找到”是 Piral 提供的默认菜单项)
为什么我会收到此错误?
- 皮拉尔 0.12.4
- Piral CLI 0.12.4
- Piral CLI Webpack 0.12.4