【发布时间】:2016-10-25 23:12:33
【问题描述】:
在我的前端,我使用 Flux 调度程序运行 React。我也在运行 web-pack-dev 服务器。
在研究了“Unexpected Token”错误后,我不断得出这个解决方案:babel-loader jsx SyntaxError: Unexpected token
但是,我的 webpack.config.js 文件中包含了这个预设,并且只有在 Flux 的调度程序中包含一个数组时才会出现这个错误。我在下面包含了我为测试而构建的功能。这在只传递一个对象时完美运行,但在传递数组时会引发错误。
Module build failed: SyntaxError: /Users/foo/sites/app/js/actions/TripActions.js: Unexpected token (33:6)
31 | country: "Spain",
32 | complete: false
> 33 | },
| ^
34 | {
35 | id: 987655432,
36 | text: "Another Great Flat!",
我正在测试的函数
export function reloadTrip() {
dispatcher.dispatch({type: "FETCH_TRIPS"});
setTimeout(() => {
dispatcher.dispatch({type: "RECIEVE_TRIPS", [
{
id: 123456789,
text: "Nice flat for you and me",
city: "Madrid",
country: "Spain",
complete: false
},
{
id: 987655432,
text: "Another Great Flat!",
city: "Paris",
country: "France",
complete: true
}
]});
}, 1000);
}
【问题讨论】:
标签: reactjs flux webpack-dev-server babeljs