3

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?

godblessstrawberry
  • 4,556
  • 2
  • 40
  • 58

1 Answers1

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