[英]Have Error : SyntaxError: Unexpected token, expected “,” - I am trying to return an array where the keys name: and timestamp: are present
[英]I have an unexpected token error. Where is it coming from?
有人告訴我mapStateToProps函數中出現意外的令牌錯誤,但找不到。 您能看一下並告訴我問題是什么嗎?
import React from 'react'
import { connect } from 'react-redux'
import { Redirect } from 'react-router-dom'
const mapStateToProps = state =>({
config: state.config,
receipt: { receiptProducts = [] },
expeditedShipping: state.expeditedShipping.expeditedProduct
})
@connect(mapStateToProps)
我計算機上的錯誤顯示為...
ERROR in ./src/client/app/cbd-
mobile/components/receipt/ReceiptComponent.js
Module build failed: SyntaxError: Unexpected token, expected , (8:26)
6 | config: state.config,
7 | receipt: { receiptProducts = [] },
> 8 | expeditedShipping: state.expeditedShipping.expeditedProduct
| ^
9 | })
10 |
11 | @connect(mapStateToProps)
@ ./src/client/app/index.jsx 31:24-83
@ multi (webpack)-dev-server/client?http://localhost:8080
./src/client/app/index.jsx
webpack: Failed to compile.
提前致謝。
receipt: { receiptProducts: [] }
而非receipt: { receiptProducts = [] }
設置拆包默認值時,通常會使用{ x = [] }
const { x = [] } = someVariable
不過,在這種情況下,您只是在構建一個javascript對象,因此僅使用:
s
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.