Total Pageviews

Wednesday 15 April 2020

Loop through arrays in ReactJs

.map is ES6 feature and used with array; it returns a new array with the results of calling a function for every array element.

'key' attribute is used to uniquely identify elements.

Example:



import React from 'react';

const names = ['John''Doe''Jenny''Marie'];

function App() {

  return (
    <div className="App">
      <ul>
          {names.map(function(nameindex){
              return <li key={ index }>{name}</li>;
          })}
      </ul>
    </div>
  );
}

export default App;


Result:


3 comments:

  1. Great Article The IEEE Xplore digital library is your gateway to trusted research—journals, conferences, standards, ebooks, and educational courses—with more than 3 million articles to help you fuel imagination, build from previous research, and inspire new ideas. Node Js Projects for Final Year IEEE will pave a new way in knowledge-sharing and spreading ideas across the globe. Project Centers in Chennai for CSE Node.js Corporate Training JavaScript Training in Chennai

    ReplyDelete
  2. Incredible tips and straightforward. This will be exceptionally helpful for me when I get an opportunity to begin my blog.
    nodejs software developers

    ReplyDelete

Microsoft Logo using flexbox and Reactjs

 <!DOCTYPE html> <html> <head>     <script src="https://unpkg.com/react@18/umd/react.development.js" crossori...