Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

react component key prop

function ListItem(props) {
  // Correct! There is no need to specify the key here:  return <li>{props.value}</li>;}

function NumberList(props) {
  const numbers = props.numbers;
  const listItems = numbers.map((number) =>
    // Correct! Key should be specified inside the array.    <ListItem key={number.toString()} value={number} />  );
  return (
    <ul>
      {listItems}
    </ul>
  );
}

const numbers = [1, 2, 3, 4, 5];
ReactDOM.render(
  <NumberList numbers={numbers} />,
  document.getElementById('root')
);
Comment

PREVIOUS NEXT
Code Example
Javascript :: electron iframe require is not defined 
Javascript :: mock click function functinal component enzyme 
Javascript :: how to write a funcat in javascript 
Javascript :: 15) Which of the following directive is used to initialize an angular app? A. ng-app ANSWER B.ng-model C.ng-controller D.None of the above 
Javascript :: feet to km js 
Javascript :: videojs videoJsResolutionSwitcher youtube 
Javascript :: Expo camera rotation 
Javascript :: sending json data uing fetch is empty 
Javascript :: ABORT CONTROLLER WITH ASYNC USEEFFECT REACT 
Javascript :: jq click with trigger load data 
Javascript :: node js error 
Javascript :: TypeError: db.collection Name is not a function 
Javascript :: how to add a class in classlist and remove after 100 ms using jquery 
Javascript :: how calculate number of digits of number 
Javascript :: cloudflare worker read url params 
Javascript :: juqey off click 
Javascript :: array intersection javascript es6 
Javascript :: react router v6 pass props 
Javascript :: index and id togtgher angularjs 
Javascript :: nodejs export all mongodb collections 
Javascript :: symbol properties javascript 
Javascript :: mongodb find array with element 
Javascript :: map array with only lenghth given 
Javascript :: vue js debounce input 
Javascript :: override backswipe behaviour in ios and android react native 
Javascript :: synchronous file read 
Javascript :: material icons angular 
Javascript :: emergency food meme 
Javascript :: dart how to convert json to x-www-form-urlencoded 
Javascript :: math.ceil 
ADD CONTENT
Topic
Content
Source link
Name
7+5 =