简体   繁体   English

React-Redux API文档符号

[英]React-Redux API documentation symbols

I'm reading the react-redux documentation and I found this: 我正在阅读react-redux文档 ,发现了这一点:

[mapStateToProps(state, [ownProps]): stateProps] (Function) [mapStateToProps(state,[ownProps]):stateProps](函数)

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. 我记得jQuery在它的API文档中也使用了它。 Example: 例:

.slideToggle([duration][,complete]) .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 . 因此,对于mapStateToPropsconnect是一个可选参数。 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. 应该始终使用第一个参数(即Redux状态树)来声明它,并且可以声明它采用第二个参数,该第二个参数将是给包装器组件的支持。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM