const { render } = ReactDOM;
const { Component, PropTypes } = React;
const { createHashHistory } = History;
const { Router, Route, IndexRoute, Link, useRouterHistory } = ReactRouter;
const appHistory = useRouterHistory(createHashHistory)({ queryKey: false })
/*
* Playground area: feel free to change the code below
* like you would normally do, for your app.
* If you change the components, make sure to refactor
* the routes appropriately
*/
const App = ({ children }) =>
<div>
<NavBar />
{ children }
</div>
const NavBar = () =>
<ul>
<li><Link to="/">Home</Link></li>
<li><Link to="/about">About</Link></li>
<li><Link to="/contact">Contact</Link></li>
</ul>
const Home = () =>
<div>
<h3>Home</h3>
<p>
This is React Router demo.
Play around here, see how the UI changes based on the URL.
You can use the URL bar to enter the address.
Hit 'enter' to navigate to the given address.
</p>
<p>
Feel free to collaborate on this JSFiddle to make it better. It is not perfect now.
</p>
</div>
const About = () =>
<div>
<h3>About</h3>
</div>
const Contact = () =>
<div>
<h3>Contact</h3>
<ul>
<li>Mateusz Zatorski</li>
<li>Github: <a href="https://github.com/knowbody">knowbody</a></li>
</ul>
</div>
const NotFound = () =>
<div>
<img src="http://fab404.com/wp-content/uploads/2015/03/appnovation404-472x295.jpg" alt="not found" />
</div>
/* End of playground area */
const Root = () =>
<Router history={appHistory}>
<Route component={Browser}>
{/* Add your routes below */}
<Route path="/" component={App}>
<IndexRoute component={Home} />
<Route path="about" component={About} />
<Route path="contact" component={Contact} />
<Route path="*" component={NotFound} />
</Route>
{/* ===================== */}
</Route>
</Router>
/*
* Below there are two fixed components...
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Fiddle Pages
Your fiddles accessible under a custom domain and a vanity path - the simplest hosting for your personal project.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Get Fiddle Pages with PRO
Your fiddles accessible under a custom domain and a vanity path - the simplest hosting for your personal project.