Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to integrate with typescript #52

Open
purnadi-winarno opened this issue Aug 29, 2021 · 10 comments
Open

How to integrate with typescript #52

purnadi-winarno opened this issue Aug 29, 2021 · 10 comments

Comments

@purnadi-winarno
Copy link

Hello, can you please add readme file how to integrate with typescript and redux toolkit?
since I get this error message:

Argument of type 'AsyncThunkAction<User[], void, {}>' is not assignable to parameter of type 'AnyAction'.

Thank you

@plwai
Copy link
Collaborator

plwai commented Aug 30, 2021

@purnadi-winarno

can you please provide more information? For example, the code segment which having type error.

@purnadi-winarno
Copy link
Author

purnadi-winarno commented Aug 30, 2021 via email

@plwai
Copy link
Collaborator

plwai commented Sep 1, 2021

@purnadi-winarno your image is just a path.

@purnadi-winarno
Copy link
Author

purnadi-winarno commented Sep 1, 2021 via email

@plwai
Copy link
Collaborator

plwai commented Sep 1, 2021

@purnadi-winarno

Sorry. Can you please provide the information clearly? Your image is still not showing as well.

@purnadi-winarno
Copy link
Author

purnadi-winarno commented Sep 1, 2021 via email

@jk-gan
Copy link
Owner

jk-gan commented Sep 1, 2021

hi @purnadi-winarno, can you attach the image in Github instead of replying via email? we can't see your image for some reasons.

@purnadi-winarno
Copy link
Author

purnadi-winarno commented Sep 1, 2021 via email

@mi-chal
Copy link

mi-chal commented Oct 17, 2021

@purnadi-winarno
Here's an example for store config that uses Redux-Saga but it can be applied for other middlewares:

import { configureStore, Middleware } from '@reduxjs/toolkit';
import createDebugger from 'redux-flipper';
import createSagaMiddleware from 'redux-saga';

import rootReducer from '@/store/rootReducer';
import rootSaga from '@/store/rootSaga';

const sagaMiddleware = createSagaMiddleware();

const middlewares: Middleware[] = [sagaMiddleware];

if (__DEV__) {
  const reduxFlipperDebugger = createDebugger();
  middlewares.push(reduxFlipperDebugger);
}

const store = configureStore({
  reducer: rootReducer,
  middleware: (getDefaultMiddleware) => [
    ...getDefaultMiddleware({
      thunk: false,
    }),
    ...middlewares,
  ],
});

sagaMiddleware.run(rootSaga);

export default store;

I hope it helps :)

@MathisBarre
Copy link

And here is an example with redux-toolkit :

import {configureStore, Middleware} from '@reduxjs/toolkit';
import userReducer from './user/userSlice';

const middlewares: Middleware[] = [];

if (__DEV__) {
  const createDebugger = require('redux-flipper').default;
  middlewares.push(createDebugger());
}

export const store = configureStore({
  reducer: {
    user: userReducer,
  },
  middleware: getDefaultMiddleware =>
    getDefaultMiddleware().concat(middlewares),
});

export type RootState = ReturnType<typeof store.getState>;
export type AppDispatch = typeof store.dispatch;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants