react-on-rails
Advanced tools
Comparing version 6.4.0 to 6.4.1
@@ -11,2 +11,5 @@ # Change Log | ||
### Possible Breaking Change | ||
- Since foreman is no longer a dependency of the React on Rails gem, please run `gem install foreman`. If you are using rvm, you may wish to run `rvm @global do gem install foreman` to install foreman for all your gemsets. | ||
### Fixed | ||
@@ -13,0 +16,0 @@ - Removed foreman as a dependency. [#678](https://github.com/shakacode/react_on_rails/pull/678) by [x2es](https://github.com/x2es). |
@@ -22,5 +22,5 @@ 'use strict'; | ||
var _isRouterResult = require('./isRouterResult'); | ||
var _isCreateReactElementResultNonReactComponent = require('./isCreateReactElementResultNonReactComponent'); | ||
var _isRouterResult2 = _interopRequireDefault(_isRouterResult); | ||
var _isCreateReactElementResultNonReactComponent2 = _interopRequireDefault(_isCreateReactElementResultNonReactComponent); | ||
@@ -142,3 +142,3 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
if ((0, _isRouterResult2.default)(reactElementOrRouterResult)) { | ||
if ((0, _isCreateReactElementResultNonReactComponent2.default)(reactElementOrRouterResult)) { | ||
throw new Error('You returned a server side type of react-router error: ' + (0, _stringify2.default)(reactElementOrRouterResult) + '\nYou should return a React.Component always for the client side entry point.'); | ||
@@ -145,0 +145,0 @@ } else { |
@@ -25,5 +25,5 @@ 'use strict'; | ||
var _isRouterResult = require('./isRouterResult'); | ||
var _isCreateReactElementResultNonReactComponent = require('./isCreateReactElementResultNonReactComponent'); | ||
var _isRouterResult2 = _interopRequireDefault(_isRouterResult); | ||
var _isCreateReactElementResultNonReactComponent2 = _interopRequireDefault(_isCreateReactElementResultNonReactComponent); | ||
@@ -65,13 +65,22 @@ var _buildConsoleReplay = require('./buildConsoleReplay'); | ||
if ((0, _isRouterResult2.default)(reactElementOrRouterResult)) { | ||
if ((0, _isCreateReactElementResultNonReactComponent2.default)(reactElementOrRouterResult)) { | ||
// We let the client side handle any redirect | ||
// Set hasErrors in case we want to throw a Rails exception | ||
hasErrors = !!reactElementOrRouterResult.routeError; | ||
if (hasErrors) { | ||
console.error('React Router ERROR: ' + (0, _stringify2.default)(reactElementOrRouterResult.routeError)); | ||
} else if (trace) { | ||
var redirectLocation = reactElementOrRouterResult.redirectLocation; | ||
var redirectPath = redirectLocation.pathname + redirectLocation.search; | ||
console.log('ROUTER REDIRECT: ' + name + ' to dom node with id: ' + domNodeId + ', redirect to ' + redirectPath); | ||
} | ||
if (reactElementOrRouterResult.redirectLocation) { | ||
if (trace) { | ||
var redirectLocation = reactElementOrRouterResult.redirectLocation; | ||
var redirectPath = redirectLocation.pathname + redirectLocation.search; | ||
console.log('ROUTER REDIRECT: ' + name + ' to dom node with id: ' + domNodeId + ', redirect to ' + redirectPath); | ||
} | ||
// For redirects on server rendering, we can't stop Rails from returning the same result. | ||
// Possibly, someday, we could have the rails server redirect. | ||
} else { | ||
htmlResult = reactElementOrRouterResult.renderedHtml; | ||
} | ||
} else { | ||
@@ -78,0 +87,0 @@ htmlResult = _server2.default.renderToString(reactElementOrRouterResult); |
{ | ||
"name": "react-on-rails", | ||
"version": "6.4.0", | ||
"version": "6.4.1", | ||
"description": "react-on-rails JavaScript for react_on_rails Ruby gem", | ||
@@ -5,0 +5,0 @@ "main": "node_package/lib/ReactOnRails.js", |
@@ -122,5 +122,5 @@ [![Build Status](https://travis-ci.org/shakacode/react_on_rails.svg?branch=master)](https://travis-ci.org/shakacode/react_on_rails) [![Codeship Status for shakacode/react_on_rails](https://app.codeship.com/projects/cec6c040-971f-0134-488f-0a5146246bd8/status?branch=master)](https://app.codeship.com/projects/187011) [![Dependency Status](https://gemnasium.com/shakacode/react_on_rails.svg)](https://gemnasium.com/shakacode/react_on_rails) [![Gem Version](https://badge.fury.io/rb/react_on_rails.svg)](https://badge.fury.io/rb/react_on_rails) [![npm version](https://badge.fury.io/js/react-on-rails.svg)](https://badge.fury.io/js/react-on-rails) [![Code Climate](https://codeclimate.com/github/shakacode/react_on_rails/badges/gpa.svg)](https://codeclimate.com/github/shakacode/react_on_rails) [![Coverage Status](https://coveralls.io/repos/shakacode/react_on_rails/badge.svg?branch=master&service=github)](https://coveralls.io/github/shakacode/react_on_rails?branch=master) | ||
6. Start your Rails server: | ||
6. Ensure that you have `foreman` installed: `gem install foreman`. | ||
with foreman installed (`gem install foreman`) | ||
7. Start your Rails server: | ||
@@ -221,3 +221,3 @@ ```bash | ||
### Rails Context | ||
When you use a "generator function" to create react components or you used shared redux stores, you get 2 params passed to your function: | ||
When you use a "generator function" to create react components (or renderedHtml on the server) or you used shared redux stores, you get 2 params passed to your function: | ||
@@ -323,2 +323,4 @@ 1. Props that you pass in the view helper of either `react_component` or `redux_store` | ||
Another reason to user a generator function is that sometimes in server rendering, specifically with React Router, you need to return the result of calling ReactDOMServer.renderToString(element). You can do this by returning an object with the following shape: { renderedHtml, redirectLocation, error }. | ||
#### Renderer Functions | ||
@@ -346,3 +348,3 @@ A renderer function is a generator function that accepts three arguments: `(props, railsContext, domNodeId) => { ... }`. Instead of returning a React component, a renderer is responsible for calling `ReactDOM.render` to manually render a React component into the dom. Why would you want to call `ReactDOM.render` yourself? One possible use case is [code splitting](docs/additional-reading/code-splitting.md). | ||
+ **component_name:** Can be a React component, created using a ES6 class, or `React.createClass`, a generator function that returns a React component, or a renderer function that manually renders a React component to the dom (client side only). | ||
+ **component_name:** Can be a React component, created using a ES6 class, or `React.createClass`, a generator function that returns a React component (or only on the server side, an object with shape { redirectLocation, error, renderedHtml }), or a renderer function that manually renders a React component to the dom (client side only). | ||
+ **options:** | ||
@@ -349,0 +351,0 @@ + **props:** Ruby Hash which contains the properties to pass to the react object, or a JSON string. If you pass a string, we'll escape it for you. |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
111668
806
579