react-subrouter
Links
How to use
- SubRouter requires Childrens.
- Children should have 'url' and 'Component' properties
- ChildrenComponent inherits the 'synthesized url'.
- A key is automatically generated inside the SubRouter. You don't have to manipulate the key.
Example of usage
- Install
npm install --save xadparo-react-subrouter
- Use in react.js
import React, { Component } from 'react'
import { Switch, Link } from 'react-router-dom'
import SubRouter from 'xadparo-react-subrouter'
class TempPage extends Component {
render() {
var parentUrl = '/temp'
return (
<SubRouter path={ parentUrl }>
{
...[
{ key: 123, value: 'qwe' },
{ key: 456, value: 'asd' },
{ key: 789, value: 'zxc' },
].map(obj => {
var { key, value } = obj
return {
{ url: key, component: () => value }
}
})
}
<SubRouter>
)
}
}
export default TempPage