How to get result from matching conditions in React?

Viewed 19

Raw Data

const data = [
{name: "Amy", country: "Japan", color: "Red", age: 10 },
{name: "Bob", country: "Japan", color: "Green", age: 20 },
{name: "Clara", country: "Spain", color: "Blue", age: 30 }
]

Hook (name, country and color already get value)

const [name, setName] = useState('');
const [country, setCountry] = useState('');
const [color, setColor] = useState('');
const [haveData, setHaveData] = useState([]);
const [noData, setNoData] = useState([]);

UI https://i.stack.imgur.com/BtIPw.png

When I click "Query", how can I get result as following? Thank you.

https://i.stack.imgur.com/Tkwle.png

setHaveData([{name: "Amy", country: "Japan", color: "Red", age: 10 }, {name: "Bob", country: "Japan", color: "Green", age: 20 }]) setNoData([{name: "Clara", country: "Spain", color: "Blue", age: 30 }])

0 Answers
Related