I have a react component with props like below. what i am trying to do is to set the default values to the dropdown when page loads. i tried this with a dummy array and it works fine. but when i pass the array via props from another component the value is not setting.
export interface dropdownProps {
list: [];
defaultSelectedList: number[];
}
// const defaultSelectedList = [123, 432, 987]; **this works if i set a dummy array**
console.log(defaultSelectedList, 'test');
const Dropdown: FC<DropdownProps> = (props) => {
const methods = useForm<{ dropdown: number[] }>({
defaultValues: {
dropdown: defaultSelectedList
},
});
}
<FormProvider {...methods}>
<MultiSelect
name="dropdown"
list={list}
/>
</FormProvider>
when i console the value initially the value is undefined and then the value is set. i am guess this could be the issue. can anyone help me with this
