I'm reading the react-redux documentation and I found this:
[mapStateToProps(state, [ownProps]): stateProps] (Function)
I don't understand exactly what " [ ] " means, or what is the " : " symbol used for in this context. I remember that jQuery also uses this for it's API documentation. Example:
.slideToggle([duration][,complete])
Is there any convention for writing/reading these?
“ []”表示不是必需的,但可以使用。
Brackets indicate that a parameter is optional, colons indicate some kind of type declaration.
So, for mapStateToProps
: it is an optional argument to connect
. It should always be declared with a first parameter which will be the Redux state tree, and may be declared to take a second parameter which will be the props given to the wrapper component.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.