Given the code below, we use the map() function to take an array of numbers and double their values. We assign the new array returned by map() to the variable doubled and log it:
You can build collections of elements and include them in JSX using curly braces {}.
Usually you would render lists inside a component.
Keys help React identify which items have changed, are added, or are removed.
Keys only make sense in the context of the surrounding array.
Keys used within arrays should be unique among their siblings. However, they don’t need to be globally unique.
map() function returns a map object(which is an iterator) of the results after applying the given function to each item of a given iterable (list, tuple etc.) ... fun : It is a function to which map passes each element of given iterable.
A “key” is a special string attribute you need to include when creating lists of elements in React. Keys are used to React to identify which items in the list are changed, updated, or deleted. In other words, we can say that keys are used to give an identity to the elements in the lists
The spread operator is a useful and quick syntax for adding items to arrays, combining arrays or objects, and spreading an array out into a function’s arguments.
In JavaScript, spread syntax refers to the use of an ellipsis of three dots (…) to expand an iterable object into the list of arguments.
“Spread operator to the rescue! It looks similar to rest parameters, also using ..., but does quite the opposite.” — JavaScript.info
The he … spread operator is useful for many different routine tasks in JavaScript, including the following:
- Copying an array
- Concatenating or combining arrays
- Using Math functions
- Using an array as arguments
[...["😋😛😜🤪😝"]] // Array [ "😋😛😜🤪😝" ] [..."🙂🙃😉😊😇🥰😍🤩!"] // Array(9) [ "🙂", "🙃", "😉", "😊", "😇", "🥰", "😍", "🤩", "!" ]
const hello = {hello: "😋😛😜🤪😝"} const world = {world: "🙂🙃😉😊😇🥰😍🤩!"}
const helloWorld = {...hello,...world} console.log(helloWorld) // Object { hello: "😋😛😜🤪😝", world: "🙂🙃😉😊😇🥰😍🤩!" }
You can pass state values to a child component as a prop, but you can also pass functions directly to the child component like this: <ChildComponent
// The child component will access using actionName
actionName={this.actual_action_name}
/>
The Increment( ) function determines the next node at the same level. You can also increase the level of a node by one at a specified level
In order to do this, you need to do the following steps:
1- Create a callback function in the parent component. This callback function will get the data from the child component. 2- Pass the callback function in the parent as a prop to the child component. 3- The child component calls the parent callback function using props.
In order to execute a function from a child component, you will need to use Refs. React supports a special attribute that you can attach to any component, that's the ref attribute, it takes a callback function, and you can access the functions of the child component in the parent accessing this




