react-router 5.0.0和react 16.8有问题
使用NavLink应用程序可以按预期工作,但使用Link时出现错误
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, or you might have mixed up default and named imports.
import React, { Component } from 'react';
import { Link } from 'react-router-dom';
import { Content } from '../../components/content/Content';
export class Home extends Component {
render() {
return (
<Content>
<Link to="/">Home Page</Link>
</Content>
);
}
}
[已解决] 将功能组件转换为类时,我不会重新启动应用程序。第一个没有 Router
提供的 history
属性
最佳答案
来自错误消息:
you might have mixed up default and named imports
您应该混合导入语句。请遵循以下约定来解决您的问题:
import Content from '...';
// for a default export
而不是命名导出:
import { Content } from '...'
// for a named export
关于javascript - React-router <Link> 无法正确使用 React 16.8,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55326158/