1.3.3 • Published 7 years ago

redux-routes-renderer v1.3.3

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

Redux.Routes.Renderer

A Promise interface for rendering isomorphic React Redux components in Node.

An example implementation can be found in v2 of React.Router.Pagination.IO.

A companion package, react-routes-renderer, is for React applications without Redux.

Example

In your web server:

const { Renderer } = require('redux-routes-renderer')

const renderer = new Renderer()

Configure your store:

const { configureStore } = require('./path/to/store')

const store = configureStore()

In your web server's request handler:

const routes = require('./path/to/routes')
const path = '/request/path'

renderer.render(store, routes, path)
  .then((o) => {
    /*
     *  Your success response
     */
  .catch((e) => {
    /*
     *  Your failure response
     */
  });

If React Router can match the request path to a route definition and it is rendered, then your server's success response handler will receive an object which looks like:

{ rendered: /* String */ }

The rendered string will be whatever is returned from ReactDOMServer.renderToString().

If React Router matches the request path to a redirect definition, then your success response handler will receive an object which looks like:

{ redirect: /* Object */ }

The redirect object will be whatever location is returned from match().

If match() encounters an error, or ReactDOMServer.renderToString() encounters an error, then your error response handler will receive an error object; this is a 500 Internal Server Error.

If match() cannot match the request path to a route definition, then your error response handler will receive a different error; this is a 404 Not Found.

1.3.3

7 years ago

1.3.2

7 years ago

1.3.1

7 years ago

1.3.0

7 years ago

1.2.9

7 years ago

1.2.8

7 years ago

1.2.7

7 years ago

1.2.6

7 years ago

1.2.5

7 years ago

1.2.4

7 years ago

1.2.3

8 years ago

1.2.2

8 years ago

1.2.1

8 years ago

1.2.0

8 years ago

1.0.2

8 years ago

1.0.1

8 years ago