Simple React Router
How do I make an simple react router?
Simple page navigation using React Router v2.8.1. What is a simple react router? How do you make a simple react router? This script and codes were developed by Dan on 07 January 2023, Saturday.
Simple React Router - Script Codes HTML Codes
<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>Simple React Router</title>
</head>
<body> <!-- All your HTML really needs is an element to append all the JSX in the JS file to. -->
<div id="root-entry"></div> <script src='https://cdnjs.cloudflare.com/ajax/libs/react/15.3.1/react.min.js'></script>
<script src='https://cdnjs.cloudflare.com/ajax/libs/react/15.3.1/react-dom.min.js'></script>
<script src='https://cdnjs.cloudflare.com/ajax/libs/react-router/2.8.1/ReactRouter.min.js'></script> <script src="js/index.js"></script>
</body>
</html>
Simple React Router - Script Codes JS Codes
"use strict";
// You want to import the Router, Route, IndexRoute and Link from React Router.
var _ReactRouter = ReactRouter;
var Router = _ReactRouter.Router;
var Route = _ReactRouter.Route;
var IndexRoute = _ReactRouter.IndexRoute;
var Link = _ReactRouter.Link;
// A main React component using this.props.children will pull in all the children Routes in the router function at the bottom.
var App = React.createClass({ displayName: "App", render: function render() { return React.createElement( "div", null, this.props.children ); }
});
var Home = React.createClass({ displayName: "Home", render: function render() { return React.createElement( "div", null, React.createElement( "h1", null, "Home Page" ), React.createElement( "ul", null, React.createElement( "li", null, React.createElement( Link, { to: "link-one" }, "Link 1" ) ), React.createElement( "li", null, React.createElement( Link, { to: "link-two" }, "Link 2" ) ) ) ); }
});
var LinkOne = React.createClass({ displayName: "LinkOne", render: function render() { return React.createElement( "div", null, React.createElement( "h1", null, "Link 1 Page" ), React.createElement( Link, { to: "/" }, "Back Home" ) ); }
});
var LinkTwo = React.createClass({ displayName: "LinkTwo", render: function render() { return React.createElement( "div", null, React.createElement( "h1", null, "Link 2 Page" ), React.createElement( Link, { to: "/" }, "Back Home" ) ); }
});
// Set a "home" route of "/" to work with the main "App" component, then use IndexRoute with the "Home' component to set it as the initial component rendered.
ReactDOM.render(React.createElement( Router, null, React.createElement( Route, { path: "/", component: App }, React.createElement(IndexRoute, { component: Home }), React.createElement(Route, { path: "link-one", component: LinkOne }), React.createElement(Route, { path: "link-two", component: LinkTwo }) )
), document.getElementById('root-entry'));
Developer | Dan |
Username | danbuda |
Uploaded | January 07, 2023 |
Rating | 4 |
Size | 2,707 Kb |
Views | 4,048 |
Find the perfect freelance services for your business! Fiverr's mission is to change how the world works together. Fiverr connects businesses with freelancers offering digital services in 500+ categories. Find Developer!
Name | Size |
Alphabetizing Lists with JavaScript | 2,719 Kb |
Sass Mixin Example | 1,944 Kb |
Just Some Buttons | 1,568 Kb |
Simple Collapsable Navbar | 2,667 Kb |
Sticky Footer | 1,655 Kb |
React Routing with this.props.children | 2,725 Kb |
Simple Grid | 1,960 Kb |
CSS Grid Using Inline-Block | 1,800 Kb |
React Collapsable Navbar | 3,531 Kb |
Sorting Items While Ignoring Articles | 3,002 Kb |
Jasper is the AI Content Generator that helps you and your team break through creative blocks to create amazing, original content 10X faster. Discover all the ways the Jasper AI Content Platform can help streamline your creative workflows. Start For Free!
Name | Username | Size |
Custom checkbox example | Capelo | 3,495 Kb |
Rainbow Drops | Csbarnes | 2,365 Kb |
3D flipping card | Ssaakkaa | 2,238 Kb |
AngularJS Skills | Supro | 3,312 Kb |
CSS only simple parallax scroll | Stanssongs | 3,708 Kb |
Pictos font library from CodePen | Jstam | 3,790 Kb |
Scarlett Johansson Tribute Page | Diomed | 3,233 Kb |
Background-blend-mode Test | 0x04 | 4,744 Kb |
SVG Scalable Text | Said_FD | 1,451 Kb |
Basic HTML5 Structure | YuvarajTana | 1,289 Kb |
Surf anonymously, prevent hackers from acquiring your IP address, send anonymous email, and encrypt your Internet connection. High speed, ultra secure, and easy to use. Instant setup. Hide Your IP Now!