0.0.24 • Published 7 years ago

react-router-router v0.0.24

Weekly downloads
5
License
MIT
Repository
github
Last release
7 years ago

Simple Express.js router middleware for sites that use React Router.

Server

import express from 'express'
import RouterServer from 'react-router-router/server'
import routes from './routes'
import reducers from './reducers' // Redux reducers

let app = express()
let router = RouterServer({ routes, reducers })

app.set('port', (process.env.PORT || 5000))

// The page will look for a JavaScript file at `main.js`. 
// I’m webpacking the client script to `public/main.js` and using the `public/` directory for static assets
app.use(express.static('public'))
app.use('/', router);

app.listen(app.get('port'), function () {
  console.log('Listening at port', app.get('port'))
});

Client

import RouterClient from 'react-router-router/client'
import routes from './routes'
import reducers from './reducers' // Redux reducers

RouterClient({ routes, reducers })

Routes

import React from 'react'
import { Route, IndexRoute } from 'react-router'
import Home from './components/home'
import About from './components/about'

let routes = (
  <Route path="/">
    <IndexRoute component={Home} />
    <Route path="about" component={About} />
  </Route>
)

export default routes

Reducers

// A sample Redux reducer
function text(state = 'Call me Ishmael.', action) {
  switch (action.type) {
    case 'UPDATE':
      return action.value
    default:
      return state
    }
}

export default {
  text
}
0.0.24

7 years ago

0.0.23

8 years ago

0.0.22

8 years ago

0.0.21

8 years ago

0.0.20

8 years ago

0.0.19

8 years ago

0.0.17

8 years ago

0.0.16

8 years ago

0.0.15

8 years ago

0.0.14

8 years ago

0.0.13

8 years ago

0.0.12

8 years ago

0.0.11

8 years ago

0.0.10

8 years ago

0.0.9

8 years ago

0.0.8

8 years ago

0.0.7

8 years ago

0.0.6

8 years ago

0.0.5

8 years ago

0.0.4

8 years ago

0.0.3

8 years ago

0.0.2

8 years ago

0.0.1

8 years ago