0

I am try to use redux-dynamic-modules with typescript. It shows this error. can some one help me.

I implemented this with javascript. github link. But when I try to convert this to type script I am in a trouble.

This is the redux-dynamic-modules documentation

and also I wrote a alternative solution for use my project. can some one say is this have any side effect or can someone give idea to improve this code - repo link

enter image description here

this is the store.ts file

export const store: IModuleStore<any> = createStore(
    {
        initialState: {},
    },
   
);

this is authSlice.ts file

export type KeycloakInfo = {isAuthenticated: boolean, token: string, realm: string}

//realms defined in keycloak
export const realms = ['aaa', 'bbb'];

const initialState = {
    isAuth: false,
    keycloakInfo: { isAuthenticated: false, token: '', realm: '' }
}

const authSlice = createSlice({
    name: 'auth',
    initialState,
    reducers: {
        setAuth: (state, action: PayloadAction<KeycloakInfo>) => {
           state.isAuth = !state.isAuth;
           state.keycloakInfo = action.payload
       }
    }
})

export const { setAuth } = authSlice.actions;

export default authSlice.reducer; 

this is the authModule.ts file

import { IModule } from "redux-dynamic-modules";

import authSlice from "../features/authSlice";

export const AuthModule: IModule<any> = {
    id: "auth",
    reducerMap: {
        auth: authSlice,
    },

};

when I try to call the DynamicModuleLoader it shows

import {store as rootStore} from "/shared-state/store";
import  {AuthModule} from "/shell/authentication";
import { Provider } from 'react-redux';
import { DynamicModuleLoader } from 'redux-dynamic-modules';

const root = ReactDOM.createRoot(
  document.getElementById('root') as HTMLElement
);
root.render(
  <Provider store={rootStore}>
    <DynamicModuleLoader modules={[AuthModule]}>
      <App />
    </DynamicModuleLoader>
  </Provider>
);

0 Answers0