【发布时间】:2019-11-15 14:03:28
【问题描述】:
<Route path='/confirmAccount/:link' component={ConfirmationPage} />
这行代码在浏览器控制台抛出错误---> "Uncaught SyntaxError: Unexpected token
<Route path='/confirmAccount' component={ConfirmationPage} />
没有 '/:link' 可以正常工作并完美呈现。
我不知道如何使用"Uncaught SyntaxError: Unexpected token < bundle.js:1" 作为错误消息来解决此问题
import React from 'react';
import { connect } from 'react-redux'
import Grid from '@material-ui/core/Grid'
class ConfirmationPage extends React.Component {
render() {
//let loading = this.props.loading;
let loading = true;
return (
<Grid container>
<Grid>
{(loading) && 'Confirming Account. Please wait ....'}
</Grid>
</Grid>
)
}
}
const mapStateToProps = ({auth}) => {
const { loading } = auth;
return ({
loading
})
}
export default connect(mapStateToProps)(withStyles(styles)(ConfirmationPage));
更新:答案部分中此特定问题的解决方案
【问题讨论】:
-
这里看起来不错。它可能来自您的组件或其他地方
-
当我转到“localhost:9000/confirmAccount”时,组件会重新渲染。但是当我转到 'localhost:9000/confirmAccount/someString' 时,它会因“Uncaught SyntaxError: Unexpected token
-
你能发布你的组件的最小可重现代码吗?
-
在问题中添加了最小组件
标签: javascript reactjs react-router-dom