DEV Community

taler-hash
taler-hash

Posted on

How to use fixed options in react-select?

Heres my fetched data and sets the CONNECT isFixed value to true
useEffect(() => {
async function fetched_roles() {
const response = await axios.get("/rmsroles");
let newresponse = response !== null &&
(response.data).map((role) => (
role.role == 'CONNECT' ?
{ value : role.role , label : role.role , isFixed: 'true' }
:
{ value : role.role , label : role.role , isFixed: 'false' }
))
setIsLoading(false);
setRoles(newresponse);
}
fetched_roles();
}, []);

Here's my Select Component
<Select
name="roles"
onChange={handleGetRoles}
isMulti
isLoading={isLoading}
options={roles}
components={animatedComponents}
/>

I don't clearly understand in the documentation in react-select
This is what I wanted in react select

This is my react select i want to fixed CONNECT in selected options

Top comments (0)