编译一个简单的 React 应用程序时,我在文件的最后(空白)行收到一条错误消息,提示“意外的令牌”import { Link, Redirect } from "react-router-dom";import './App.css';class Companies extends Component { constructor(props) { super(props); var user = null; if (props.hasOwnProperty("user")){ user = props["user"]; } this.state = { user: user, companies: [], }; }}export Companies是我试图运行的代码Failed to compile../src/Companies.js Line 22:1: Parsing error: Unexpected token 20 | 21 | export Companies> 22 | | ^是我收到的错误信息。
1 回答
白猪掌柜的
TA贡献1893条经验 获得超10个赞
要导出类,正确的语法是: export default Class
尝试这个:
import { Link, Redirect } from "react-router-dom";
import './App.css';
class Companies extends Component {
constructor(props) {
super(props);
var user = null;
if (props.hasOwnProperty("user")){
user = props["user"];
}
this.state = {
user: user,
companies: [],
};
}
}
export default Companies
添加回答
举报
0/150
提交
取消