'How to dynamically update the defaultValue in material UI RadioGroup
I have 2 radio buttons named as "Open" and "Closed". The result is displayed depending upon the value of { status: "Open" } or { status : "Closed"}. My question is how do you understand whether the setFilter() result array length is 0 or >0 ? Following is the code,
<RadioGroup
row
aria-label={groupName}
name={groupName}
defaultValue={options[0].value}
onChange={e => setFilter(groupName, e.target.value)}>
{options.map(option => (
<FormControlLabel
key={option.value}
value={option.value}
control={<Radio className={classes.darkRadio} />}
label={<Typography variant={"caption"}>{option.label}</Typography>}
/>
))}
</RadioGroup>
where groupName="status" and e.target.value="Open" or "Closed". Also as I am new to react can anybody explain me how setFilter works ? And how the setFilter result is displayed on screen ?
I am actually trying to change the defaultValue depending upon the result of "Open" or "Close". So if "Open" result array length is 0 then change the default selection to "Close" and vice-versa. I have searched for setFilter many times, looks like it is just a variable and is mentioned in this link, https://github.com/TanStack/react-table/discussions/2247
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
