Open hbole opened 3 years ago
Afaik in next-redux-wrapper 7, you should be using createWrapper<Store>(makeStore, {debug: true});
, (where Store
is ReturnType<typeof makeStore>
) not createWrapper<State>(makeStore, {debug: true});
Hi I am having the same issue more less
Argument of type '({ store }: Store<any, any>) => Promise<{ props: {}; }>' is not assignable to parameter of type 'GetStaticPropsCallback<Store<any, any>, any>'.
Type 'Promise<{ props: {}; }>' is not assignable to type 'GetStaticProps<any, ParsedUrlQuery>'.
Type 'Promise<{ props: {}; }>' provides no match for the signature '(context: GetStaticPropsContext<ParsedUrlQuery>): GetStaticPropsResult<any> | Promise<GetStaticPropsResult<any>>'.ts(2345)
export const getStaticProps = wrapper.getStaticProps(async ({ store}) => {
...
return {
props: {},
};
});
const reducer = (state: any, action: any) => {
if (action.type === HYDRATE) {
const nextState = {
...state, // use previous state
...action.payload, // apply delta from hydration
};
return nextState;
}
return RootReducers(state, action);
};
export const initStore = () =>
createStore(reducer, bindMiddleware([thunkMiddleware]));
export type AppRootStateType = ReturnType<typeof RootReducers>;
export const wrapper = createWrapper<ReturnType<typeof initStore>>(initStore);
please note that I made comment here as well, not sure if the same issue https://github.com/kirill-konshin/next-redux-wrapper/issues/407
I fix it forget about it. :-)
I change the line
export const getStaticProps = wrapper.getStaticProps(async ({ store}) => {
to
export const getStaticProps = wrapper.getStaticProps(store => async context => {
getting the same error in _App.tsx
class MyApp extends App
if (ctx.req) {
ctx.store.dispatch(END);
await (ctx.store as SagaStore).sagaTask?.toPromise();
}
return {
pageProps,
};
};
Describe the bug
Getting a couple of type errors while creating the store. This error started coming in when I upgraded the wrapper from version
6.0.2
to7.0.2
Errors are as below:Attaching the code, and screenshots of the code & error given above. The same code works without throwing an error with
next-redux-wrapper
v6.0.2
not sure what has changed on the latest version.To Reproduce
There is no template created on CodeSandBox as this is typescript related or syntactical error
Steps to reproduce the behavior: Code snippets
store -> index.tsx
store -> reducers.tsx
Expected behavior
The above code snippets work absolutely fine with
next-redux-wrapper
version6.0.2
without throwing any type errors or syntactical errors. Expectednext-redux-wrapper
version7.0.2
to work in a similar way. But not working with the latest versions.Screenshots
Attaching screenshots of code & the errors
errors
error on web
Desktop (please complete the following information):
Version: 94.0.4578.0 (Official Build) canary (64-bit)
Please help me to resolve this issue. Currently using an older version
6.0.2
for the time being until this gets resolved. Thank you.