I don't know how to use Navigate in React router v6.
I'm trying to redirect to loggedPath if user is true.
But i don't know syntax to pass loggedPath argument to <Navigate to = ${loggedPath}
/>
import { Route, Navigate } from "react-router-dom";
export function IsUserRedirect({ user, loggedPath, children, ...rest }){
return (
<Route
{...rest}
element ={ !user ? children : user && <Navigate to = `${loggedIath}` /> }
/>
)}
and this is Error message
- Parsing error: JSX value should be either an expression or a quoted
JSX text - '{' expected.
- Expression expected.
- Unterminated regular expression literal.
- Declaration or statement expected.
Thank you for help
CodePudding user response:
You have to wrap it in {} when you use ``