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 :: get ip address with js 
Javascript :: es6 modules node 
Javascript :: Regex for number divisible by 5 
Javascript :: mongoose discriminator 
Javascript :: delete embeds field discord.js 
Javascript :: wait 0.5 after function javascript 
Javascript :: sorting algorithms in node.js 
Javascript :: callback vs return 
Javascript :: update array usestate 
Javascript :: js split method 
Javascript :: angular get route last segment 
Javascript :: d3.js on click event 
Javascript :: js fit window to content 
Javascript :: how to check if username already exists in database using javascript 
Javascript :: iis express gzip 
Javascript :: first unique character in a string javascript 
Javascript :: password regex javascript 
Javascript :: es6 range 
Javascript :: python json nested dictionaries 
Javascript :: what is ajax 
Javascript :: in if condition how to set alert music in javascript 
Javascript :: javascript sort multi-dimensional array by column 
Javascript :: javascript url 
Javascript :: usestate previous state 
Javascript :: javascript ajax receive multiple values 
Javascript :: side effect, useEffect, return 
Javascript :: data-toggle="tooltip not working due to jquery-ui.min.js 
Javascript :: email valid javascript 
Javascript :: Alpine.js: button using @click function not working 
Javascript :: send json file to kafka topic 
ADD CONTENT
Topic
Content
Source link
Name
2+3 =