I loved PrimeReact but when I migrated to PrimeReact the only issue I got is the following:
ISSUE
When setting a default value, the value doesn't set
This code below is in Material UI code to set a default value but can not migrate this function for PrimereReact (dropdown) component.
Where do we add this code:
- The problem is we have to set its state when a row is rendered
- The problem occurs if we set the state in our row function
Can this be fixed, I am surprised that no one has reported this. Or have I missed it?
I am trying to explain as much detail as possible. Maybe I have missed anything but can not figure it out.
Infor me if you need more details of the code or information I am glad to provide them.
This code below is in Material UI code
THIS ROW
defaultValue={row?.userLevel}
Code: Select all
<div className="col-12 sm:col-12 md:col-6 lg:col-3">
<FormControl fullWidth="true">
<InputLabel id="userlevel">User Level</InputLabel>
<Select
labelId="userlevel"
label="User Level"
defaultValue={row?.userLevel}
onChange={(e) =>
setData({ ...data, userLevel: e.target.value })
}
>
<MenuItem value={5}>Super User</MenuItem>
<MenuItem value={1}>Regular User</MenuItem>
</Select>
</FormControl>
</div>