I am experiencing an issue where these lines of code throwing Too many re-renders. React limits the number of renders to prevent an infinite loop error. Can anyone please help me to find out what is causing this issue?
options = useSelector(state => {
if(!props.disabled) {
if(props.values) {
return props.values
} else if(props.dispatch) {
dispatch({type: props.dispatch});
return state[props.getFrom] ? state[props.getFrom] : []
}
} else {
return [];
}
});
Basically the usecase here is, On component load, I want to call a dispatch where an api will get hit and result will be stored in redux store. Then that values I want to render in dropdown in the same component!
Thanks in advance!