我正在浏览 React documentation当他们同时将函数参数包装到方括号和圆括号中时,对他们在这里试图说的内容感到有点困惑 React.Children.map(children, function[(thisArg)])
function[ (thisArg)]
。谁能解释一下是什么意思?
最佳答案
是meant这意味着 .map
接受可选的第三个参数,即 thisArg
来调用传递的函数。但是文档中给出的语法非常困惑。换一种更标准的方式,它将是:
React.Children.map(children, functionToInvoke[, thisArg])
或
React.Children.map(children, function(child, index)[, thisArg])
这是怎么回事MDN does it , 将可选参数放在方括号中在所需参数陈述之后。
关于javascript - function[(thisArg)]) 语法是什么意思?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58210254/