我正在经历React documentation,当他们在React.Children.map(children, function[(thisArg)])
中同时将函数参数包装到方括号和圆括号中时,他们对这里要说的function[(thisArg)]
感到有些困惑。谁能解释这个意思?
答案 0 :(得分:4)
meant表示.map
接受一个可选的第三个参数,它是用来调用传递函数的thisArg
。但是文档中给出的语法非常混乱。用更标准的方式来说,应该是:
React.Children.map(children, functionToInvoke[, thisArg])
或
React.Children.map(children, function(child, index)[, thisArg])
MDN does it的用法,将可选参数放在方括号之后的必填参数中。