Skip to content

Instantly share code, notes, and snippets.

@frivolta
Created May 27, 2022 15:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save frivolta/ff2d33ceb27dc9bfbdb9922b5c7ff12c to your computer and use it in GitHub Desktop.
Save frivolta/ff2d33ceb27dc9bfbdb9922b5c7ff12c to your computer and use it in GitHub Desktop.
Write better React, compose multiple functional HoCs, Higher-Order Components - Array.prototype.map
// Result is [2,3,4]
[1,2,3].map((number)=>number+1)
// Note that you can extract the callback function and pass it to the map function:
function addOne(arg){
return arg+1
}
[1,2,3].map((number)=>addOne(number))
// or
[1,2,3].map(addOne)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment