https://github.com/danieldunderfelt/react-response-router
A simple response handler that handles server-side rendering your React-router project.
https://github.com/danieldunderfelt/react-response-router
Last synced: 5 months ago
JSON representation
A simple response handler that handles server-side rendering your React-router project.
- Host: GitHub
- URL: https://github.com/danieldunderfelt/react-response-router
- Owner: danieldunderfelt
- License: mit
- Created: 2016-02-14T12:48:47.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2016-02-14T19:25:17.000Z (over 10 years ago)
- Last Synced: 2025-11-02T10:06:05.916Z (8 months ago)
- Language: JavaScript
- Size: 13.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
React-response
===
React-router response handler
---
This package provides a React-router-integrated response handler for [React-response](https://github.com/danieldunderfelt/react-response). It is built to integrate with React-response, but there's actually nothing here that stops it from being used in vanilla servers. The only (peer)dependency is React-router.
This readme assumes that you are somewhat familiar with React-response.
### How to use it
When you have a React-response server build set up, simply import `createReactRouterResponse` from this package and call it with your React-router route config. Then give the returned function to the `` component of React-response as the `handler` prop. Like this:
```javascript
// In your React-response server setup:
{(renderProps, req, res) => {
return { component: ReactDOM.renderToString(
) }
}}
```
Make sure to render `` from React-router with the `renderProps`. Consult [the documentation](https://github.com/reactjs/react-router/blob/latest/docs/guides/ServerRendering.md) of React-router for more information.
The above can also be accomplished like this:
```javascript
```
Note that `` will dislike being called without its renderProps. This is a one-time warning when you start the server and will not impede the functionality of your app.
# Test and build
This project uses Tape and Sinon for testing and Gulp as its build system. Run the test suite with `gulp test`. Build the package with `gulp build`
# Collaboration
PR's welcome! Please add tests for all changes and follow the general coding style. Semicolons are banned ;)
Please send all issues to [React-response's issue tracker](https://github.com/danieldunderfelt/react-response/issues).