Invariant Violation: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined. You likely forgot to export your component from the file it's defined in.
报错如上。我的代码如下:
router.get('*', (req, res) => {
// console.log(routes)
match({ routes: routes, location: req.url }, (error, redirectLocation, renderProps) => {
if (error) {
res.send(500, error.message)
} else if (redirectLocation) {
res.redirect(302, redirectLocation.pathname + redirectLocation.search)
} else if (renderProps) {
console.log(renderToString(<RoutingContext {...renderProps} />));
} else {
res.send(404, 'Not found')
}
});
});
routes.js
const routes = (
<Route path="/" component={Home}/>
);
export default routes;