Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

li key attribute

//A “key” is a special string attribute you need 
//to include when creating lists of elements.

function NumberList(props) {
  const numbers = props.numbers;
  const listItems = numbers.map((number) =>
    <li key={number.toString()}>      {number}
    </li>
  );
  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 :: netlify refresh page not found 
Javascript :: javascript object array merge 
Javascript :: set delay javascript 
Javascript :: how to print numbers in javascript 
Javascript :: how to access model data in jsp spring mvc 
Javascript :: transition event listener does not work 
Javascript :: vue ref add class 
Javascript :: react native transform 
Javascript :: download image jquery onclick 
Javascript :: json schema array of objects 
Javascript :: get DOM node with xpath 
Javascript :: store array in localstorage 
Javascript :: js decode base64 
Javascript :: angular json pipe pretty 
Javascript :: js stop redirect 
Javascript :: javascript get local storage 
Javascript :: fetchData from json file 
Javascript :: how to find the last item in an array 
Javascript :: reset navigation to specific tab react-navigation 
Javascript :: create phone number javascript 
Javascript :: javascript get last item in array 
Javascript :: javascript swap two variables 
Javascript :: how to negate a boolena variable javascript 
Javascript :: vue js default prop 
Javascript :: express start template 
Javascript :: docker react js 
Javascript :: how to add a shadow react native 
Javascript :: node js module export class 
Javascript :: javascript maximum date 
Javascript :: Get day first 3 letters name js 
ADD CONTENT
Topic
Content
Source link
Name
8+3 =