[英]I have an unexpected token error. Where is it coming from?
I'm being told there is an unexpected token error in my mapStateToProps function, but I'm failing to find it. 有人告诉我mapStateToProps函数中出现意外的令牌错误,但找不到。 Can you take a look and tell me what the problem is?
您能看一下并告诉我问题是什么吗?
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)
The error from my computer reads... 我计算机上的错误显示为...
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.
Thanks in advance. 提前致谢。
receipt: { receiptProducts: [] }
instead of receipt: { receiptProducts = [] }
receipt: { receiptProducts: [] }
而非receipt: { receiptProducts = [] }
You would typically use { x = [] }
when setting a default value for unpacking 设置拆包默认值时,通常会使用
{ x = [] }
const { x = [] } = someVariable
in this case, though, you're just building a javascript object, so you only use :
s 不过,在这种情况下,您只是在构建一个javascript对象,因此仅使用
:
s
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.