filter array react code example

Example 1: filter array react

{people.filter(person => person.age < 60).map(filteredPerson => (
  • {filteredPerson.name}
  • ))}

    Example 2: react filter

    import React from 'react';
    
    const people = [
      {
        name: 'James',
        age: 31,
      },
      {
        name: 'John',
        age: 45,
      },
      {
        name: 'Paul',
        age: 65,
      },
      {
        name: 'Ringo',
        age: 49,
      },
      {
        name: 'George',
        age: 34,
      }
    ];
    
    function App() {
      return (
        
    {people.filter(person => person.age < 60).map(filteredPerson => (
  • {filteredPerson.name}
  • ))}
    ); } export default App;

    Example 3: render a list using array filter react

    react rendering using array.filter

    Tags:

    Misc Example