Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

[PrivateRoute] is not a component. All component children of must be a or

//App.js
import PrivateRoute from "PrivateRoute";
...
return (
	...
		<Routes>
			<Route exact path='/login' element={<Login/>}/>
			<Route exact path='/' element={<PrivateRoute component={HomePage}/>}/>
		</Routes>
	...
)

//PrivateRoute.js
export default function PrivateRoute({ component: Component, ...rest }) {

    const isLogged = false;

    // If authorized, return an outlet that will render child elements
    // If not, return element that will navigate to login page
    return isLogged ? <Component/> : <Navigate to="/login" />;
}
Comment

Error: [Home] is not a component. All component children of must be a or

<Route exact path="/" element={<><AddTodo addTodo={addTodo} /><Todos todos={todos} onDelete={onDelete} /></>} />
Comment

PREVIOUS NEXT
Code Example
Javascript :: boolean constructor js 
Javascript :: javascript if shorthand 
Javascript :: for of loop javascript 
Javascript :: moment time format by country 
Javascript :: how to get single element from nested array mongoose 
Javascript :: store data to the browser’s localStorage 
Javascript :: get client id socket io 
Javascript :: using dto in node js 
Javascript :: js clear all select options 
Javascript :: django pass list to javascript 
Javascript :: how to remove minutes with moment js 
Javascript :: download jquery 
Javascript :: object deep copy 
Javascript :: como actualizar nodejs 
Javascript :: javascript indexof 
Javascript :: if classlist contains js 
Javascript :: js create json array 
Javascript :: convert arraybuffer to file javascript 
Javascript :: how to get array from number length 
Javascript :: get Two digit number js 
Javascript :: moment get start of week in datetime 
Javascript :: how to change materil ui divider coloer 
Javascript :: javascript in keyword 
Javascript :: js capitalize word 
Javascript :: javascript override shortcut 
Javascript :: clean url javascript 
Javascript :: javascript copy to clipboard 
Javascript :: how to set input date to today date on initialization 
Javascript :: mathjax new line 
Javascript :: js different 
ADD CONTENT
Topic
Content
Source link
Name
8+2 =