My issue is explained on this live example : https://stackblitz.com/edit/stackblitz-starters-qcvjsz?file=src%2FApp.tsx
Basically I’m passing a list of options to a radio button list, with the state and setter to a child component rendered with createPortal, however when the options are clicked in the child the parent component updates it’s state, but not the child, so the radio never have the checked status.
2
Answers
We need to create a separate state to maintain the data of the modal, this can be used to separately maintain the modal data
Apart from this please ensure that the key is unique for all sets of labels and checkboxes, also for a group of checkboxes the name field should be the same and unique when compared to other groups, this is the reason for your issues.
stackblitz
I think that in order to get the modal to update, that you need to maintain state within the modal itself.
I have a running modified version of the project here. The main change is in
SelectedYearModal.jsx
where I added a state variable that I use for rendering within the modal and I update the local state variable on selection within the modal.