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 :: killall node 
Javascript :: javascript string repeat 
Javascript :: array destructuring js 
Javascript :: javascript string error 
Javascript :: Javascript object convert into JSON 
Javascript :: react functional components shortcut in webstorm 
Javascript :: react onchange multiple functions 
Javascript :: react js docker 
Javascript :: convert js date to utc 
Javascript :: nodejs postgresql local connection 
Javascript :: React native calender date picker 
Javascript :: vue js get routes 
Javascript :: maximum sum array algorithm javascript 
Javascript :: remove an element from array javascript 
Javascript :: find duplicate element on array 
Javascript :: subset in js 
Javascript :: how make calender in bootstrap 
Javascript :: swr data fetching 
Javascript :: javascript regex One or more occurrences of the pattern 
Javascript :: create callback function javascript 
Javascript :: how manipulate the multiple input option data in one function in vue js 
Javascript :: javascript read word document 
Javascript :: selected text 
Javascript :: react Spread Attributes conditionally 
Javascript :: how to load js in vuejs components 
Javascript :: pull out only text from element javascript 
Javascript :: how to change size of button in react native 
Javascript :: how to redirect to another page after clicking ok in alert 
Javascript :: js join two arrays 
Javascript :: how to create an array in javascript 
ADD CONTENT
Topic
Content
Source link
Name
4+8 =