Created
June 15, 2023 14:03
-
-
Save Dromediansk/e20ca520df8234565e9718dc5aef2171 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { useMemo } from 'react'; | |
const EmployeeList = ({ employees, positionFilter }) => { | |
const filteredEmployees = useMemo(() => { | |
return employees.filter(employee => employee.position === positionFilter); | |
}, [employees, positionFilter]); | |
return ( | |
<div> | |
<h2>Employee List</h2> | |
<ul> | |
{filteredEmployees.map(employee => ( | |
<li key={employee.id}> | |
{employee.name} - {employee.position} | |
</li> | |
))} | |
</ul> | |
</div> | |
); | |
}; | |
export default EmployeeList; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment