I am following a course in which a condition is made to know if the user is logged in or not, however I receive an error despite having the same code as in the video.
I am using react-router-dom V6.
This is the code:
const logged = false;
<Route path='/profile' component={ProfilePage}>
{
logged ?
() => {
(<ProfilePage />)
}
: () => {
alert('You must start session')
return (<Redirect to='/login' />)
}
}
</Route>
Error: Functions are not valid as a React child. This may happen if you return a Component instead of <Component />
from render. Or maybe you meant to call this function rather than return it.