react-collider
Advanced tools
Comparing version
@@ -60,1 +60,4 @@ 'use strict'; | ||
} | ||
// Export for non-express apps | ||
module.exports.collider = runRouter |
{ | ||
"name": "react-collider", | ||
"version": "1.5.3", | ||
"version": "1.6.0", | ||
"description": "Express middleware for isomorphic express + react apps", | ||
@@ -5,0 +5,0 @@ "main": "lib/reactCollider.js", |
# React-collider | ||
Express middleware for isomorphic Express + React apps. | ||
Express middleware for isomorphic Express + React apps. Also usable for any [NodeJs app without Express](https://github.com/Youpinadi/react-collider#usage-without-express). | ||
@@ -104,4 +104,20 @@ Check out the `example` folder for a working example, including data-fetching from the Dailymotion API. | ||
### Client side app only | ||
## Client side app only | ||
If your servers are down and you can't pre-render the pages server-side, your app will still work client side (assuming your API is okay). All you need is to send a basic html file with your app bundled. Check out the `example` folder for an example. | ||
## Usage without Express | ||
You can use react-collider wihtout express. You can simply use it to get the React component to render and the data to use: | ||
```javascript | ||
var collider = require('react-collider').collider, | ||
routes = require('./routing') | ||
var url = '/video' | ||
// simply provide your routes and the url | ||
collider(routes, url, function(Handler, data) { | ||
var page = React.renderToString(React.createElement(Handler, {data: data})) | ||
}) | ||
``` |
@@ -23,2 +23,6 @@ var assert = require('chai').assert, | ||
it('should export a collider function', function() { | ||
expect(collider.collider).to.be.a('function') | ||
}) | ||
it('should render a page with no data', function(done) { | ||
@@ -25,0 +29,0 @@ request(server) |
@@ -19,3 +19,10 @@ var assert = require('chai').assert, | ||
it('should return an object with components as keys and data', function(done) { | ||
it('should return an object with components as keys and data - Video', function(done) { | ||
runRouter(routes, '/', function(Handler, data) { | ||
expect(data).to.have.all.keys('Sidebar', 'HomeContent') | ||
done() | ||
}) | ||
}) | ||
it('should return an object with components as keys and data - Home', function(done) { | ||
runRouter(routes, '/video', function(Handler, data) { | ||
@@ -22,0 +29,0 @@ expect(data).to.have.all.keys('Sidebar', 'Video') |
16787
6.43%368
3.08%123
14.95%