0.1.2 • Published 8 years ago

react-redux-render v0.1.2

Weekly downloads
3
License
CC0-1.0
Repository
github
Last release
8 years ago

React Redux Render

HTTP middleware for rendering React Redux apps on the server.

Build Status Coverage Status license npm npm

Installation

npm install --save react-redux-render

Example

server.js

import http from 'http';
import compose from 'lodash/function/compose';
import { connect } from 'http-middleware-metalab';
import base from 'http-middleware-metalab/base';
import webpack from 'http-middleware-metalab/webpack';
import send from 'http-middleware-metalab/middleware/send';
import empty from 'http-middleware-metalab/middleware/empty';

import renderReactRedux from 'react-redux-render';

import Root from './containers/root';
import createStore from './store';

const createApp = compose(
  base(),
  webpack({ assets: { stats: './build/client/stats.json' } }),

  renderReactRedux({
    rootComponent: Root,
    createStore,
  }),
  
  send(),
  empty
);

export default connect(createApp(), http.createServer());

Config Options

Option NameTypeDescription
rootComponentComponentYour root app component. Receives the Redux Store as a single prop when rendered.
createStoreFunctionReturn a new Redux store.
renderRootFunctionUse this instead of options.rootComponent if your app has a more complicated entry point. Receives the Redux store as a arguments and returns a string of markup.
mapStateFunctionReturn an object with the shape { status, title, path, locale }.
mapAssetsFunctionReceives the Redux state and the request object as arguments returns an object with the shape { styles[], scripts[] }.
staticRenderBooleanUse reactDOM.renderToStaticMarkup when rendering options.rootComponent. Has no effect if options.renderRoot is specified.
waitObjectPass configuration into reduxPromiseWait.
0.1.2

8 years ago

0.1.1

8 years ago

0.1.0

8 years ago