react-on-rails
Advanced tools
Comparing version 6.0.4 to 6.0.5
@@ -8,5 +8,9 @@ # Change Log | ||
## [6.0.5] | ||
##### Added | ||
- Added better error messages to avoid issues with shared redux stores [#470](https://github.com/shakacode/react_on_rails/pull/470). | ||
## [6.0.4] | ||
##### Fixed | ||
- Added polyfill for clearTimeout which is used by babel-polyfill. | ||
- Added polyfill for clearTimeout which is used by babel-polyfill [#451](https://github.com/shakacode/react_on_rails/pull/451). | ||
@@ -353,3 +357,4 @@ ## [6.0.3] | ||
[Unreleased]: https://github.com/shakacode/react_on_rails/compare/6.0.4...master | ||
[Unreleased]: https://github.com/shakacode/react_on_rails/compare/6.0.5...master | ||
[6.0.5]: https://github.com/shakacode/react_on_rails/compare/6.0.4...6.0.5 | ||
[6.0.4]: https://github.com/shakacode/react_on_rails/compare/6.0.3...6.0.4 | ||
@@ -356,0 +361,0 @@ [6.0.3]: https://github.com/shakacode/react_on_rails/compare/6.0.2...6.0.3 |
@@ -81,5 +81,9 @@ 'use strict'; | ||
* the setStore API is different in tha it's the actual store hydrated with props. | ||
* @param stores (key is store name, value is the store generator) | ||
* @param stores (keys are store names, values are the store generators) | ||
*/ | ||
registerStore: function registerStore(stores) { | ||
if (!stores) { | ||
throw new Error('Called ReactOnRails.registerStores with a null or undefined, rather than ' + 'an Object with keys being the store names and the values are the store generators.'); | ||
} | ||
_StoreRegistry2.default.register(stores); | ||
@@ -86,0 +90,0 @@ }, |
@@ -33,3 +33,3 @@ 'use strict'; | ||
* Register a store generator, a function that takes props and returns a store. | ||
* @param storeGenerators { name: component } | ||
* @param storeGenerators { name1: storeGenerator1, name2: storeGenerator2 } | ||
*/ | ||
@@ -44,2 +44,5 @@ | ||
var store = storeGenerators[name]; | ||
if (!store) { | ||
throw new Error('Called ReactOnRails.registerStores with a null or undefined as a value ' + ('for the store generator with key ' + name + '.')); | ||
} | ||
@@ -63,11 +66,15 @@ _storeGenerators.set(name, store); | ||
return _stores.get(name); | ||
} else { | ||
if (throwIfMissing) { | ||
var storeKeys = (0, _from2.default)(_stores.keys()).join(', '); | ||
console.log('storeKeys', storeKeys); | ||
throw new Error('Could not find hydrated store with name \'' + name + '\'. ' + ('Hydrated store names include [' + storeKeys + '].')); | ||
} else { | ||
return; | ||
} | ||
} | ||
var storeKeys = (0, _from2.default)(_stores.keys()).join(', '); | ||
if (storeKeys.length === 0) { | ||
var msg = 'There are no stores hydrated and you are requesting the store ' + (name + '. This can happen if you are server rendering and you do not call ') + 'redux_store near the top of your controller action\'s view (not the layout) ' + 'and before any call to react_component.'; | ||
throw new Error(msg); | ||
} | ||
if (throwIfMissing) { | ||
console.log('storeKeys', storeKeys); | ||
throw new Error('Could not find hydrated store with name \'' + name + '\'. ' + ('Hydrated store names include [' + storeKeys + '].')); | ||
} | ||
}, | ||
@@ -74,0 +81,0 @@ |
{ | ||
"name": "react-on-rails", | ||
"version": "6.0.4", | ||
"version": "6.0.5", | ||
"description": "react-on-rails JavaScript for react_on_rails Ruby gem", | ||
@@ -5,0 +5,0 @@ "main": "node_package/lib/ReactOnRails.js", |
@@ -15,2 +15,3 @@ [![Build Status](https://travis-ci.org/shakacode/react_on_rails.svg?branch=master)](https://travis-ci.org/shakacode/react_on_rails) [![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) | ||
# NEWS | ||
* 2016-06-13: 6.0.4 shipped with a critical fix regarding a missing polyfill for `clearTimeout`, used by babel-polyfill. | ||
* 2016-06-06: 6.0.2 shipped with a critical fix if you are fragment caching the server generated React. | ||
@@ -161,3 +162,3 @@ * *See [NEWS.md](NEWS.md) for more notes over time.* | ||
Inside your Rails views, you can now use the `react_component` helper method provided by React on Rails. You can pass props directly to the react component helper. You can also initialize a Redux store with view helper `redux_store` so that the store can be shared amongst multiple React components. Your best bet is to scan the code inside of the [/spec/dummy](spec/dummy) sample app. | ||
Inside your Rails views, you can now use the `react_component` helper method provided by React on Rails. You can pass props directly to the react component helper. You can also initialize a Redux store with view or controller helper `redux_store` so that the store can be shared amongst multiple React components. See the docs for `redux_store` below and scan the code inside of the [/spec/dummy](spec/dummy) sample app. | ||
@@ -329,5 +330,9 @@ ### Client-Side Rendering vs. Server-Side Rendering | ||
For an example, see [spec/dummy/app/controllers/pages_controller.rb](spec/dummy/app/controllers/pages_controller.rb). | ||
For an example, see [spec/dummy/app/controllers/pages_controller.rb](spec/dummy/app/controllers/pages_controller.rb). Note, this is preferable to using the equivalent view_helper `redux_store` in that you can be assured that the store is initialized before your components. | ||
#### View Helper | ||
`redux_store(store_name, props: {})` | ||
Same API as the controller extension. **HOWEVER**, we recommend the controller extension instead because the Rails executes the template code in the controller action's view file (`erb`, `haml`, `slim`, etc.) before the layout. So long as you call `redux_store` at the beginning of your action's view file, this will work. However, it's an easy mistake to put this call in the wrong place. Calling `redux_store` in the controller action ensures proper load order, regardless of where you call this in the controller action. Note, you won't know of this subtle ordering issue until you server render and you find that your store is not hydrated properly. | ||
`redux_store_hydration_data` | ||
@@ -334,0 +339,0 @@ |
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
95741
716
601