Question: i want to redirect to page "/items" if isAdmin true.

below is my code,

```
function Child() {
    const isAdmin = getUser();

    return isAdmin ? (
        <Confirm />
    ) : (
        <NotFound />
    );
}

```

As seen in above code, if isAdmin true then i render confirm and if isAdmin false i am rendering NotFound.

But this will render NotFound within Parent component.

Instead i want to redirect to NotFound. How can I do it? Could someone help me with this. Thanks.

EDIT:
what i have tried?

```
return isAdmin ? (
    <Confirm />
) : (
    <Route component={NotFound} />
);

```

But this still renders in same page.

i have used the same code in main component like below,

```
function Main() {
    return (
        <Switch>
            <Route
                exact
                path="/home"
                render={routeProps => (
                    <Layout>
                        <Home {...routeProps} />
                    </Layout>
                )}
             />
             //other routes here
             <Route component={NotFound}/> //if none of the urls match then                    //renders notfound
         </Switch>
     );
 }

```

how do i use something similar. thanks.

Answer: 
if you're using `react-router-dom` `react-router` you can use the code like

i want to redirect to page "/items" if isAdmin true.

below is my code,

```
function Child(props) {
    const isAdmin = getUser();

    return isAdmin ? (
       props.history.push('/confirm')
    ) : (
        props.history.push('/notFound')
    );
}

```

you need to have routes declared in the path `/confirm` & `notFound` in your routes.js or any where route is declared
```js
const Child = (props) => {
    const isAdmin = getUser();
    return (props.history.push(isAdmin ? '/confirm' : '/notFound');
}
```

You need to use `history.push`.