View EditGroupRoute.test.jsx
import React from 'react'
import { renderComponent } from '../../test_helper'
import EditGroupRoute, { check } from '../../../src/modules/groups/routes/EditGroupRoute'
describe('EditRoute', () => {
const rendered = () => <div>rendered</div>
const loading = () => <div>loading</div>
const Else = () => <div>else</div>
const E = () => <EditGroupRoute component={rendered} else={Else} loadingComponent={loading} />
let state
View history.js
const connect = require('react-redux').connect
const router = require('react-redux-saga-router').default
const sagaMiddleware = require('redux-saga').default
app.use('*', (req, res) => {
const serverHistory = {
location: require('url').parse(request.url)
action: 'PUSH',
listen: () => null
}
View Menu.jsx
import { makePath } from 'react-redux-saga-router'
// if we have a route like this:
//const a = <Route name="foo" path="/my/:fancy/path(/:wow/*supercomplicated(/:thing))" />
export default () => {
<a href={makePath('foo', { fancy: 'pants' })}>links to /my/pants/path</a>
<a href={makePath('foo', {
fancy: 'pants',
wow: 'yes',
supercomplicated: '/this/works/just/fine'
View Routes.jsx
import Routes from 'react-redux-saga-router/Routes'
import Route from 'react-redux-saga-router/Route'
import * as actions from './actions'
const stateFromParams = (params) =>
(params.id === 'new') ? { id: true } : { id: params.id ? params.id : false }
function paramsFromState(state) {
if (state.records.selectedRecord) {
return {
View Routes.jsx
import Routes from 'react-redux-saga-router/Routes'
import Route from 'react-redux-saga-router/Route'
export default () => (
<Routes>
<Route name="about" path="/about" />
</Routes>
)
View AboutToggleLoadingWithElse.jsx
import AboutToggleLoading from './AboutToggleLoading.jsx'
const About = () => <div>About a specific thing</div>
const Else = () => <div>List of all things we are about</div>
const Loading = () => <div>Loading things...</div>
export const () => (
<AboutToggleLoading component={About} else={Else} loadingComponent={Loading} />
)
View AbouteRouteLoading.jsx
import AboutToggleLoading from './AboutToggleLoading.jsx'
const About = () => <div>About things</div>
const Loading = () => <div>Loading things...</div>
export const () => (
<AboutToggleLoading component={About} loadingComponent={Loading} />
)
View AboutToggleLoading.jsx
import * as selectors from 'react-redux-saga-router/selectors'
import { Toggle } from 'react-redux-saga-router/Toggle'
export default Toggle(state => selectors.matchedRoute('about'),
state => !state.loading)
View AboutRoute.jsx
import AboutToggle from './AboutToggle.jsx'
const About = () => <div>About things</div>
export const () => (
<AboutToggle component={About} />
)
View AboutToggle.jsx
import * as selectors from 'react-redux-saga-router/selectors'
import { Toggle } from 'react-redux-saga-router/Toggle'
export default Toggle(state => selectors.matchedRoute('about'))