I'm currently mastering redux and haven't really figured out how to output the data you get from the server using thunk. I in useEffect do a thunk dispatch, get server data, but they don't output because they come after a couple of seconds, so in useState just an empty array, and in store the desired data
// retrieve data from the store
const servicesData = useAppSelector((state) => state.services.services);
const [services, setServices] = useState(servicesData);
// store
export const store = createStore(
reducers,
{},
composeWithDevTools(applyMiddleware(thunk))
);
I understood that useState does not pick up data that comes after a couple of seconds, it turns out it is necessary to add data through setState, but then why thunk? is it necessary to use it at all when receiving any data? I'm completely confused