I'm using the SWR
In my code I am using the junction of both as follows
const vehiclesStates = useSelector(({ vehiclesStates: state }) => state); // REDUX
const response = useFetch("/vehicles/states") // SWR
const dispatch = useDispatch(); // REDUX
// REDUX
useEffect(() => {
if(response.data) dispatch(VehiclesStatesActions.setVehiclesStates(response.data.result))
}, [response.data, dispatch]);
if(response.error) return <div>ERROR - {response.error.toString()}</div> // SWR
else if(!response.data) return <div>LOADING</div> // SWR
// If there is a return I render my component
return (<></>)
In this excerpt above I set my component state in redux with the data that I return using the SWR (Integrated with axios). That way, in any other component that needs to use that same data, I only import it with redux's useSelect.
This way
const vehiclesStates = useSelector(({ vehiclesStates: state }) => state);
I find it more practical than just using the SWR by calling useFetch on each component that wants to use that data.
My question is: Is using this way a correct way, or can it affect performance or something?
Thanks in advance