new array returned by map();
two steps :
Each list item needs a unique key.
Keys help React identify which items have changed, are added, or are removed.
const numbers = [1, 2, 3, 4, 5];
const listItems = numbers.map((number) =>
<li key={number.toString()}>
{number}
</li>
);
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.
1- Copying an array
2- Adding an item to a list
3- Combining objects
4- Converting NodeList to an array
const fruits = ['π','π','π','π','π']
const moreFruits = [...fruits];
console.log(moreFruits) // Array(5) [ "π", "π", "π", "π", "π" ]
fruits[0] = 'π'
console.log(...[...fruits,'...',...moreFruits]) // π π π π π ... π π π π π
const fewFruit = ['π','π','π']
const fewMoreFruit = ['π', 'π', ...fewFruit]
console.log(fewMoreFruit) // Array(5) [ "π", "π", "π", "π", "π" ]
const objectOne = {hello: "π€ͺ"}
const objectTwo = {world: "π»"}
const objectThree = {...objectOne, ...objectTwo, laugh: "π"}
console.log(objectThree) // Object { hello: "π€ͺ", world: "π»", laugh: "π" }
const objectFour = {...objectOne, ...objectTwo, laugh: () => {console.log("π".repeat(5))}}
objectFour.laugh() // πππππ
create object ,like <person />, because function pass like prompt pass.
change a count value inside the stats by increase it by one each time of click in button.
using props consept like that nameOfFunction(this name I use it in child coponenet) = {this.nameOfFunction} this commaned shoud write down inner return in parent component.
using props like that this.props.nameOfFunction() inner child component.