import React, { useEffect, useState } from "react";
const HelloWorld = () => {
const [result, setResult] = useState([]);
// useEffect(() => {
// filterDeveloper();
// }, []);
const data = [
{
name: "Rajasekar",
title: "Developer",
},
{
name: "Ganesh",
title: "Manager",
},
{
name: "Arun",
title: "Developer",
},
];
const filterDeveloper = () => {
let test = data.filter((item) => {
return item.title === "Manager";
});
setResult(test);
};
const style1 = {
color:"white"
}
const style= {
backgroundColor: "red",
...style1
}
return (
<>
{result.map((item, index) => (
<div key={item.name} className="test" style={style}>
{index + 1} {item.name} - {item.title}
</div>
))}
<button onClick={filterDeveloper}>Test</button>
</>
);
};
export default HelloWorld;
For further actions, you may consider blocking this person and/or reporting abuse
Top comments (0)