I am creating a modal for my React / Redux application and found some great answers in this post.
One thing I cannot figure out though is where "the root of [my] component hierarchy" is.
My application is structured as below:
app.js
const jsx = (
<React.StrictMode>
<Provider store={store}>
<AppRouter />
</Provider>
</React.StrictMode>
)
AppRouter.js
...
return (
<React.Fragment>
<LoadingSpinnerFullPage />
<Router history={history}>
<Suspense fallback={<LoadingSpinnerFullPage />}>
<div className="appContainer">
<Route exact path={SidebarLocation.path} render={(props) => privatePath({component: Sidebar})} />
<div className="app-MainContent content-container-parent ">
<Route exact path={HeaderLocation.path} render ={(props) => privatePath({component: Header, ...props})} />
<Switch>
Where would my component "hierarchy root" be considered to be located?
Is it
- directly under
<React.Fragment>
? - alongside all routes directly under
< Router >
? - at the same level as
< AppRouter />
in app.js inside< Provider >
?
If my modal is connected to the redux store listening to modal.isOpen
- would placing it in the Router cause re-rendering of my entire app each time the modal is opened or closed?
Many thanks! /K