victorkvarghese / react-native-boilerplate

🚀 Type Based Architecture for developing React Native Apps using react, redux, sagas and hooks with auth flow
MIT License
605 stars 207 forks source link

Unable to convert the JS version of this repo to redux tool kit #30

Closed walegbenga closed 3 years ago

walegbenga commented 3 years ago

While trying to convert the JS version of this great project, I kept running into this problem

"t is not a function. (In 't(i,c)', 't' is an instance of Object)"

while trying to convert

createStore

to

configureStore

This is the

configureStore.js

import { configureStore } from '@reduxjs/toolkit'
import {  persistStore,  persistReducer,  FLUSH,  REHYDRATE,  PAUSE,  PERSIST,  PURGE,  REGISTER,} from 'redux-persist'
import AsyncStorage from '@react-native-community/async-storage';
import { createLogger } from 'redux-logger';
import createSagaMiddleware from 'redux-saga';

//import sagas from 'app/sagas';
import {
  loginReducer,
  paymentReducer,
  signupReducer
} from '../reducer';

const config = {
  key: 'root',
  storage: AsyncStorage,
  blacklist: ['loadingReducer'],
  debug: true, //to get useful logging
};

const middleware = [];
const sagaMiddleware = createSagaMiddleware();

middleware.push(sagaMiddleware);

if (__DEV__) {
  middleware.push(createLogger());
}
const reducers = persistReducer(config, {reducer:{
    loginReducer,
    signupReducer,
    paymentReducer
  }})

const store = configureStore({
  reducer: reducers,
  middleware: (getDefaultMiddleware) =>
    getDefaultMiddleware({
      serializableCheck: {
        ignoredActions: [FLUSH, REHYDRATE, PAUSE, PERSIST, PURGE, REGISTER],
      },
      thunk: false,
      ...middleware
    }),
})

let persistor = persistStore(store);
const myStore = () => {
  return { persistor, store };
};

export default myStore
//sagaMiddleware.run(sagas);

export const store = configureStore({
  reducer: {},
})

while this is

App.js

import React from 'react';
import { ActivityIndicator } from 'react-native';
import { Provider } from 'react-redux';
import storage from 'redux-persist/lib/storage'
import { PersistGate } from 'redux-persist/integration/react'
import { DefaultTheme, Provider as PaperProvider } from 'react-native-paper';
import 'react-native-gesture-handler';
import Navigator from './app/navigation';
import myStore from './app/store/configureStore';
import { enableScreens } from 'react-native-screens';
enableScreens();

const { persistor, store } = myStore();

const theme = {
  ...DefaultTheme,
  roundness: 2,
  colors: {
    ...DefaultTheme.colors,
    // primary: '#3498db',
    // accent: '#f1c40f',
  },
};

export default function Entrypoint() {
  return (
    <Provider store={store}>
      <PersistGate loading={null} persistor={persistor}>
        <PaperProvider theme={theme}>
          <Navigator />
        </PaperProvider>
      </PersistGate>
    </Provider>
  );
}

What am i doing wrong Sir?

victorkvarghese commented 3 years ago

Please verify your code again. will migrate to redux toolkit some time soon