I'm new to the Redux Toolkit, converted my code into that and everything seems fine, but dispatching gives an error:
Argument of type '(dispatch: any) => Promise' is not assignable to parameter of type 'AnyAction'.
Property 'type' is missing in type '(dispatch: any) => Promise' but required in type 'AnyAction'.ts(2345)
This is my store.ts file:
Changing from Redux to Redux Toolkit
But with TypeScript I added like this: https://codesandbox.io/s/stoic-taussig-kl8jt?file=/src/store.ts
Code where I get that error:
const dispatch = useAppDispatch();
const loadGraph = () => {
if (currentSite) {
dispatch(getFloor(currentSite.identifier)).then(() => {
console.log("Fetched floorplan");
dispatch(getGraph(currentSite.identifier)).then(() => {
console.log("Fetched model", realGraph.model);
if (currentCamera) {
dispatch(
changeActiveCamera(
currentSite.identifier,
currentCamera.identifier
)
);
}
});
});
}
};