I'm going through React documentation and got a bit confused of what they trying to say here React.Children.map(children, function[(thisArg)])
when they wrap function argument into square and round brackets simultaneously function[(thisArg)]
. Can anyone explain the meaning please?
Asked
Active
Viewed 241 times
3

godblessstrawberry
- 4,556
- 2
- 40
- 58
-
1Related: [How to interpret API documentation function parameters?](/q/10925478/4642212). – Sebastian Simon Apr 03 '22 at 13:07
1 Answers
8
It's meant to mean that .map
accepts an optional third argument, which is the thisArg
to invoke the passed function with. But the syntax given in the documentation is very confusing. Put in a more standard way, it would be:
React.Children.map(children, functionToInvoke[, thisArg])
or
React.Children.map(children, function(child, index)[, thisArg])
which is how MDN does it, putting the optional argument(s) in square brackets after the required arguments are stated.

CertainPerformance
- 356,069
- 52
- 309
- 320