score:0
just add a usertype props to each routes and create a protectedroute component
1 = teacher
2 = student
<switch>
<route path="/" exact>
<mainpage container={this.state.container}/>
</route>
<protectedroute path="/students" usertype={1} layout={teachersidenav} >
<student container={this.state.container}/>
</protectedroute>
<protectedroute path="/payam" usertype={1} layout={teachersidenav} >
<messaget container={this.state.container}/>
</protectedroute>
<route path="/payamha" usertype={2} layout={studentsidenav} >
<messages container={this.state.container}/>
</route>
</switch>
then apply a logic in the protectedroute component
Source: stackoverflow.com
Related Query
- how to create multiple Routes component in reactjs
- How to create a privately shared component library which can be used across multiple react projects
- ReactJs - how to use multiple children in a component
- How create separate component for prev/next buttons ReactJS
- How to create seperate component just for routes using react router?
- How to display a component inside a component multiple times on click in reactjs
- How to create a container component to use it multiple times?
- How to create a dynamic routing naming the routes based on props of a component in react-router-dom
- How to create Private Routes with firebase v9 reactjs
- ReactJS - how to create a dynamic ref from the parent. The child is a functional component
- How to apply authguard to routes having multiple components in reactjs
- How to avoid re-initializing component when multiple linked routes use same component
- how to set multiple routes in Hashrouter in reactjs that every page open in new page not append
- How to create component tree hierarchy from JSON? ReactJS
- ReactJs Create Reusable component with multiple different children
- How do I create a multiple page app with a login component in react?
- How to create multiple swiper instance in a react component and control one with the swipe of another?
- How can I create multiple instances of a React component (having an infinite animation) with different values for the :root variables
- How to create multiple nested routes for Front and admin pages
- How can I create multiple routes using React Router v4 (Sidebar)?
- Reactjs how to manage multiple interactions between component
- How to get data from multiple child component in ReactJS
- How to create a loader component in Reactjs
- How to add multiple classes to a ReactJS Component?
- How to create multiple page app using react
- How to access the "key" property from a reactjs component
- How do I wrap a React component that returns multiple table rows and avoid the "<tr> cannot appear as a child of <div>" error?
- ReactJS - How can I access the displayName of a component using javascript?
- How to avoid 'children with same key' when replacing state in ReactJs component
- How to pass a function as an argument to a ReactJS component in TypeScript
More Query from same tag
- How to focus when an error occurs in react-hook-form Controller?
- Do you really need to import 'React' when creating hooks? (React-hooks)
- typescript cannot find module when import svg file
- Mobile browser positions elements as if the view is 360px wide, but renders images on the page at a higher resolution. How does this work?
- Redux Toolkit RTK Query sending query parameters
- How to dynamically load module in react-native?
- Argument of type '{ status: string; DetailsAnnouncementListItemState: { items: IListItem[]; columns: undefined
- useReducer and useEffect hooks to fetch data
- Render Multiple images Supabase
- Use effect for every time that location.pathname changes
- Generate highlighted and summarized search preview using javascript
- Connect multiple inputs type number
- Can't update the specific key of state variable
- pass onChange function already argument checkbox
- React Input Element : Value vs Default Value
- How to let string coming with HTML tags to be rendered in React js?
- React js-How to prevent page reload once click on the link. Right now the whole page is getting refresh on clicking the link
- Preventing rerenders when using object as state in useState
- React's getDOMNode always return component's root DOM node instead of reffed one
- React key prop error even after adding it
- React Infinite Loop axios.all
- how can we automatically add commas to numbers being typed in SPFx react fluent textfield. ex: 1,000,000,000
- li content styling on hover
- React router: Create 'Link to' paths from objects
- onClick get value of element and pass value to next view/component as url in React
- How do I send data from child component to parent component in React
- How can I use HighchartsReact with Ref? I want to use setChartOptions and update, but it is not possible
- I have problem with fetching data in JSX react component
- Copy text to clipboard after mousePressed 2 seconds
- State in Link is not setting, returning undefined