Skip to content

Instantly share code, notes, and snippets.

@devarsh
Last active May 8, 2017 15:55
Show Gist options
  • Save devarsh/c39a56a84dfd63e62365ffcf14f18315 to your computer and use it in GitHub Desktop.
Save devarsh/c39a56a84dfd63e62365ffcf14f18315 to your computer and use it in GitHub Desktop.
Using React Router v4 Link Component With Any Framework, using Function as Child Components.
import {render} from 'react-dom'
import React from 'react'
import App from './Usage.jsx'
render(<App/>,document.getElementById('container'))
import { Route, BrowserRouter as Router } from 'react-router-dom'
import { List, ListItem } from 'react-toolbox'
import {Button} from 'react-toolbox/lib/button';
import React, { Component, PropTypes } from 'react';
import RRLink from '../components/RRLinkFunc.js'
const RrRt = () => (
<div>
<List>
<RRLink key={1} to="/home">
{
(location,handler,isActive) => {
const className = 'customRouterList'
const activeClassName = 'customRouterListActive'
const _className = isActive ? `${className} ${activeClassName}` : className;
return <ListItem caption="Home" onClick={handler} className={_className} />
}
}
</RRLink>
<RRLink key={2} to="/school">
{
(location,handler,isActive) => {
const className = 'customRouterList'
const activeClassName = 'customRouterListActive'
const _className = isActive ? `${className} ${activeClassName}` : className;
return <ListItem to={location} caption="School" onClick={handler} className={_className} />
}
}
</RRLink>
<RRLink key={3} to="/work">
{
(location,handler,isActive) => {
const className = 'customRouterList'
const activeClassName = 'customRouterListActive'
const _className = isActive ? `${className} ${activeClassName}` : className;
return <ListItem to={location} caption="Work" onClick={handler} className={_className} />
}
}
</RRLink>
</List>
<RRLink key={3} to="/work">
{
(location,handler,isActive) => {
const className = 'customRouterList'
const activeClassName = 'customRouterListActive'
const _className = isActive ? `${className} ${activeClassName}` : className;
return <Button href={location} label="Work" onClick={handler} />
}
}
</RRLink>
</div>
)
const Expose = () => (
<Router>
<div>
<RrRt/>
<Route path="/home" component={()=> <h1> Home </h1>} />
<Route path="/school" component={()=> <h1> School </h1> } />
<Route path="/Work" component={()=> <h1> Work </h1> } />
</div>
</Router>
)
export default Expose
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment