const [selected, setSelected] = useState([]);
const [hide, sethide] = useState();
<Accordion.Body>
{[
"one",
"two",
"three",
"four",
"five",
"six",
"seven",
"eight",
].map((device) => (
this.hide && <Form.Check
label={device}
name={device}
type="radio"
id={device}
onChange={(x) => insert_Checked(x.target.id)}
/>
))}
</Accordion.Body>
const insert_Checked = (val) => {
console.log(`value being passed to function : ${val}`);
setSelected((oldArray) => [...oldArray, `${val}`]);
console.log(selected);
};
I have this Container ( Accordion.Body from React-bootstrap) that has a bunch of radios. The application will push the "id" of any radio that is checked into a useState array "selected". I want to click a button that makes the selected radios disappear. my attempt at a solution was to create another use state hook hide and that's where I am stuck. Is it possible for a state hook to have an "instance" ? What other options do I have to make this work ? Any help would be appreciated.