score:0
AS I understood you want to implement a project details based on the project name.
For this kind of implementation , you can use TABS(https://material-ui.com/components/tabs/) rather than routes . To align vertical , you can use vertical section in tabs component. Route should be used , when you want to redirect to some other page .
score:0
Sidebar sample application in reactjs using react-router-dom
index.js
import React from "react";
import ReactDOM from "react-dom";
import { BrowserRouter as Router, Route, Switch } from "react-router-dom";
import "./styles.css";
import Header from "./Header";
const Home = () => (
<div className="rightside">
<h1>Home Page</h1>
</div>
);
const About = () => (
<div className="rightside">
<h1>About Page</h1>
</div>
);
const Product = () => (
<div className="rightside">
<h1>Product Page</h1>
</div>
);
const Contact = () => (
<div className="rightside">
<h1>Contact Page</h1>
</div>
);
const headerStyle = {
padding: 10,
background: "darkcyan"
};
ReactDOM.render(
<Router>
<header style={headerStyle}>Header</header>
<div className="main">
<Header />
<Switch>
<Route path="/home" component={Home} />
<Route path="/about" component={About} />
<Route path="/product" component={Product} />
<Route path="/contact" component={Contact} />
<Route path="/" component={Home} />
</Switch>
</div>
</Router>,
document.getElementById("root")
);
Header.js
import React from "react";
import { NavLink } from "react-router-dom";
import "./styles.css";
export default function Header() {
return (
<div className="leftside">
<ul>
<li><NavLink to="/home">Home</NavLink></li>
<li><NavLink to="/about">About</NavLink></li>
<li><NavLink to="/product">Product</NavLink></li>
<li><NavLink to="/contact">Contact</NavLink></li>
</ul>
</div>
);
}
styles.css
body {
margin: 0;
padding: 0;
}
.main {
display: flex;
height: 100vh;
}
.leftside {
background: darkgrey;
}
.rightside {
}
.leftside ul {
list-style-type: none;
padding: 0;
}
.leftside ul li a {
color: white;
text-decoration: none;
}
.leftside ul li {
padding: 5px 10px;
background: black;
margin: 1px 0px;
}
.leftside ul li:hover {
background: darkcyan;
color: white;
}
Source: stackoverflow.com
Related Query
- How to render dynamic component in the same page based button click from different section of same page?
- React: How do I only render a component on the page once I click on it from a mapped array?
- React, how to access the DOM element in my render function from the same component
- How do I render same component depending on the page the user is currently on?
- How to test the child component render text after the button on the parent component click with react testing library?
- How to render the React component with dynamic data realtime from socket.io high efficiency
- How to prevent my Page render when I click on the button
- How to test button that on click renders html element within the same component in React testing library, Jest?
- how to render different component on the same page
- how to pass just the function from one component to other component without passing the whole component or button click
- How to reload the same page upon a button click action i.e delete in react?
- React router how to display each component on click on the same page
- How would I animate the width of a button based on percentage, and the same for it's backgroundColor?
- How to pass the match when using render in Route component from react router (v4)
- Scroll page to the nested React component on a button click
- How to render a component on button click in React?
- How can I use react useContext , to show data from context, in the same component
- How to display the state on the same page when clicked Submit button in react
- react js render differnet component based on button click
- Scroll down the page to another React component on a button click
- How to render the same component repeatedly with the same prop?
- how to get a Component variable from another component but their both in the same file React
- Testing Library : How to render the same component multiple times without coupling
- Calculated row: How to calculate cell value of the particular column based on the values from other rows in the same column using AG Grid?
- How to iterate through a list of objects from api and render it to jsx page React functional component
- How do I control the state of this child component upon a button click in its parent?
- Need Reactjs help on how to properly pass this function from the parent to child button component
- My button needs to be clicked twice to render the new component for the first click React
- How to scroll to the particular div on button click in a single page application using react-router?
- How to render components on the same page in react
More Query from same tag
- React parsing function inside component as React Element
- Send request on unload event
- Send variables from one class to routes.js (without props)
- React how to make conditionally rendered navigation persist
- Alert component from Material UI not showing up?
- UseEffect triggering without respect to dependency array
- ReactJS - Warning: Unknown prop `onTouchTap` on <label> tag. Remove this prop from the element
- Gatsby and GraphQL: Accessing data in a template page
- React-Leaflet polygons are not being re-rendered
- How to pass contenteditable attribute to html?
- What's the best way to store a global variable for a reusable React component?
- How do I keep state persistant using local storage, react hooks, and Context Provider
- Displaying API With React Hooks
- Objects are not valid as a React child (APIs, JSON)
- React-Redux:reducer only return initial state
- How to prevent rollup from looking in parent node_modules folder
- Exclude index.html from express.static when serving React app with Express
- How to import bootstrap and fontasome in index.html reactjs app
- SVG icon rendering with weird edges
- ERROR: Firebase Database (${JSCORE_VERSION}) INTERNAL ASSERT FAILED: Reference.ts has not been loaded
- How to call image into reactjs and airtable
- How to map frontmatter subitem?
- What is causing the function to run twice in a react component where there seems to be no prop/state/context change?
- Footer overlapping content when trying to make it stay at the bottom of the page
- State not updating when printing on same function where updating in React Js
- How to break .map function
- Array inside Object inside Array - method map don't want work - Cannot read properties of undefined
- ReactJS - Can't build, minify error when using "Regex: named capturing groups"
- Namespace 'global.JSX' has no exported member 'TargetedEvent'
- How can I format time using moment.js in React JS and webpack