Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

190
Visualizações
Integrate Child with Parent Components using React & Saga

So the requirement is to decouple as much as possible so that on deleting any integrated child components, the Parent won't crash. The idea is to create Parent component with root saga middleware having Headers, footers, side bars, does the authentication and authorization and runs the root sagas. The parent Component will integrate external independent Child components/projects which has its own set of Sagas and Api calls.

What I want to achieve To decouple the following and create ChildOne and ChildTwo in separate projects and finally integrate them in Parent project as a plugin or a library but again these plugins or libraries will have its own Saga and Api calls.

Reason to decouple The company has over 30+ new projects and all these are being handled by different developers. Hence we are trying to integrate all the 30+ project to the Parent project with an intention that if the one project breaks, the others will continue to run and also the Parent won't need to adjust itself if we integrate or delete any child components like in the following structure, if we remove ChildOne component, the project will break as the path i.e., "../components/store/childone/saga" will be invalid.

I wonder if this can be achieved using injectReducer({ key: 'cartContainer', reducer }) & injectSaga({ key: 'cartContainer', saga }); but again If you can provide an idea on how to use this and where to use this either on Parent or Children and how to integrate all the children with the Parent

I am quite new to the React World so I'd appreciate your feedback Thank you..

The Current project has the following structure.

RootSaga.js

import ParentSaga from "../components/store/parent/saga"
import ChildOneSaga from "../components/store/childone/saga"
import ChildTwoSaga from "../components/store/childtwo/saga"

export default function* rootSaga() {
  yield spawn([
    ParentSaga(),
    ChildOneSaga(),
    ChildTwoSaga()
  ])
}

Here is an example of routes.js

import Parent from "../components/parent/index"
import ChildOne from "../components/childOne/index"
import ChildTwo from "../components/childOne/index""

const Routes = [

  { path: "/", component: Parent },
  { path: "/child-one", component: ChildOne },
  { path: "/child-two", component: ChildTwo }

And this is my index.js

import rootReducer from "./reducers"
import rootSaga from "./sagas"
const sagaMiddleware = createSagaMiddleware()

const store = createStore(
  rootReducer,
  composeEnhancers(applyMiddleware(sagaMiddleware))
)
sagaMiddleware.run(rootSaga)

almost 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

While it's not a direct answer to your question:

First, it looks like the Redux code you're writing there is very outdated. You should be using our official Redux Toolkit package to write Redux logic, rather than the deprecated original createStore API and handwritten reducer logic.

We have been recommending against use of sagas in almost all cases for years now. This is even more true today - RTK Query solves the data fetching use case, and the new RTK "listener" middleware does basically everything sagas can with a simpler API, smaller bundle size, and better TS support.

Please see these docs pages and posts for more details:

  • https://redux.js.org/introduction/why-rtk-is-redux-today
  • https://redux.js.org/tutorials/essentials/part-2-app-structure
  • https://redux.js.org/tutorials/fundamentals/part-8-modern-redux
  • https://redux-toolkit.js.org/api/createListenerMiddleware
  • https://blog.isquaredsoftware.com/2022/06/presentations-modern-redux-rtk/
  • https://blog.isquaredsoftware.com/2022/05/presentations-evolution-redux-async-logic/

And finally, we also have a docs page on managing code splitting:

  • https://redux.js.org/usage/code-splitting
almost 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda