callstack / repack

A Webpack-based toolkit to build your React Native application with full support of Webpack ecosystem.
https://re-pack.dev
MIT License
1.48k stars 110 forks source link

handle a module's redux state from another module #688

Closed sergiohortua closed 1 month ago

sergiohortua commented 3 months ago

Ask your Question

hi!. I have the following file structure for a project: image

In the reduxProvider folder I created a redux to handle it from other modules. Leave the following webpack configuration to share the provider, store and slice. - "It's a redux of a counter that adds, subtracts and resets." - image In the host module I already imported it and I can use the provider from the reduxProvider module. image

How can I use the reducer dispatch for increment, decrement and reset of the reduxProvider module from the host or any other module? image

sergiohortua commented 3 months ago

please help!!

sergiohortua commented 3 months ago

@jbroma ???????

rasheedk commented 2 months ago

I used redux micro front end library to dispatch actions . You need to register actions , so that u can use anywhere in app.

vlack-coder commented 2 months ago

Hi @sergiohortua , what I did on my end was that I put the miniApp reducer in the host app and I shared the folder

  shared: {
          './src/features/reduxSlice': {
            singleton: true,
            eager: true,
            requiredVersion: '1',
          },
    }

Don't put it under exposes, put it under the shared. You can also pass state as props

const MiniAPP = ({ route }: any) => {
  return (
    <ErrorBoundary name="Mini App">
      <React.Suspense fallback={<FallbackComponent />}>
        <MiniAPPNavigator params={route?.params} />
      </React.Suspense>
    </ErrorBoundary>
  );
};

I'm not sure if it's the best way, but it works... You can also manage your state in the Mini App Itself if the state does not interact with the Host App

github-actions[bot] commented 1 month ago

This issue has been marked as stale because it has been inactive for 30 days. Please update this issue or it will be automatically closed in 14 days.

github-actions[bot] commented 1 month ago

This issue has been automatically closed because it has been inactive for more than 14 days. Please reopen if you want to add more context.