不带导航栏的React Router渲染页面

时间:2019-05-07 11:58:53

标签: reactjs react-router-dom

我有以下模板页面:

const Routes = () => (

        <Switch>

            <Security issuer='<url>'
                  client_id='<id>'
                  redirect_uri={window.location.origin + '/implicit/callback'}
                  scope={['openid', 'email', 'profile', 'groups']}
                  onAuthRequired={onAuthRequired} >
                  <App>
                        <SecureRoute exact path="/" component={Home} />
                        <SecureRoute exact path='/protected' component={Protected} />
                        ........
                  </App>
            </Security>
        </Switch>)

export default Routes

我想做的是建立一条路由,例如/ testpage仅渲染我的组件。因此,例如:const TestComponent = () => <h1>title</h1>

当我将其放置在此处的安全性上方时,它仍会呈现APP(具有导航栏)。示例:

const Routes = () => (

        <Switch>
            <Route exact path="/testpage" component={TestComponent} />
            <Security issuer='<url>'
                  client_id='<id>'
                  redirect_uri={window.location.origin + '/implicit/callback'}
                  scope={['openid', 'email', 'profile', 'groups']}
                  onAuthRequired={onAuthRequired} >
                  <App>
                        <SecureRoute exact path="/" component={Home} />
                        <SecureRoute exact path='/protected' component={Protected} />
                        ........
                  </App>
            </Security>
        </Switch>)

export default Routes

这将显示TestComponent加上Component(具有导航栏)。我可以确保这不会在我在App之外定义的路由中发生吗?

0 个答案:

没有答案