I have a parent container that has this route
const App = () => {
return ( <
ProtectedRoute exact path = {
`/parent`
}
redirectTo = "/welcome"
component = {
ParentComp
}
/>
)
}
In parent Comp:
const ParentComp = (props) => ( <>
<StaticStuff/>
<ProtectedRoute exact path = {`/:id`}
redirectTo = "/welcome"
component = {
childComponent
}
</>)
Then in parent component I render a static text and a child component in a child path
When I trigger Parent route
route inside <StaticStuff>
I also see the content of children Component. but What I'm trying to do is only show StaticStuff
component then when triggering /parent/DynamicParam
then will see it under Static Stuff
.
Here's the content of Protected Route
const ProtectedRoute = ({ component: Component, ...rest }) => (
<Route {...rest} render={props => {
return isAuthorized() ? <Component {...rest} {...props} /> :
<Redirect to={{
pathname: props.redirectTo,
state: {
from: props.location
}
}} />
}
}>
</Route>)