How to prevent a component from appearing in a certain route

<Router>
            <Switch>
                <DataProvider>
                    <Route path="/" exact><App/></Route>
                    <Route path="/register" exact><Register/></Route>
                    <Header/>
                        <Route path="/main" exact><Main/></Route>
                        <Route path="/profile" exact><Profile/></Route>
                    <Footer />
                </DataProvider>
            </Switch>
        </Router>

Is there a way to restrict my <Footer/> and <Header/> components from appearing in the "/" and "/register" routes?

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.