I have an user input.
Based on that input I need to filter an array of options.
I have been able to submit the data, I am now inside my handleSubmitData function where I am writing the if conditions which should then return a filtered array of results to the screen however this is not happening. It must be to do with scope however I cannot seem to figure out what is wrong. Here is the code. Any guidance would be helpful
const Container = () => {
const [cards, setCards] = useState([
"studentCard",
"anywhereCard",
"liquidCard",
]);
const handleSubmitData = (userInput) => {
const { employmentStatus } = userInput.state;
const { earnings } = userInput.state;
if (employmentStatus === "student" && earnings < 16000) {
return cards.filter((card) => card !== "liquidCard");
}
if (employmentStatus === "student" && earnings >= 16000) {
return cards;
}
return cards;
};
return (
<div className="Container">
<UserInputForm submitData={handleSubmitData} />
{cards}
</div>
);
};
export default Container;
I have put cards within my render return part of the component but nothing happens there are no filtered cards..