I have tried this it works well with hardcoded user, I'm having an issue when im fetching user roles using axios and passing it to context, but when user tries url manually and hit enter context becomes null and no aceess or login page gets displayed. I can fetch logged in user roles in app but how to pass to context as it is in Root? App has route provider Or in have to call api from protected as well, but i dont want to it because i have landing page same as home in this example, on landing im controlling menus based logged in user roles, I thought of using context user to check if user has required roles to access menu if yes making it visible
Finally!! the solution at 16:59 was so helpful. Thank you!
I have tried this it works well with hardcoded user, I'm having an issue when im fetching user roles using axios and passing it to context, but when user tries url manually and hit enter context becomes null and no aceess or login page gets displayed.
I can fetch logged in user roles in app but how to pass to context as it is in Root? App has route provider
Or in have to call api from protected as well, but i dont want to it because i have landing page same as home in this example, on landing im controlling menus based logged in user roles, I thought of using context user to check if user has required roles to access menu if yes making it visible
I'm using typescript with React and it's not working for me when creating a Router.ts file and separating the routes.
Were you able to fix this?
@@Studytonight I left it like that, friend
Thank You🙏
Thanks, Bro
My pleasure :)
Thankyou brother
Thanks for the comment brother 🥰
import './App.css';
import { BrowserRouter as Router, Routes, Route } from 'react-router-dom'; // Import Routes and Route
import { Home } from './pages/Home';
import { Login } from './pages/Login';
import { Header } from './components/Header';
import { Private } from './utils/Private';
function App() {
return (
{/* Wrap Route in Routes */}
{/* Wrap Route in Routes */}
);
}
export default App; bro why it is not woking
thanks sir
nice
Thanks
informative video
Thanks :) Watch other videos in this Playlist too
Why this root, router file and userouter context
Root for Layout, Router file to define the Routing mechanism, and context to supply states to each child component.
painful video, too long and half unimportant thing, and wasting time
@@theoronno7709 hmmm 🧐 I will keep that in mind while creating the future videos. Thanks for the comment.