Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API Changes #309

Closed
justin808 opened this issue Mar 5, 2016 · 3 comments
Closed

API Changes #309

justin808 opened this issue Mar 5, 2016 · 3 comments
Assignees
Milestone

Comments

@justin808
Copy link
Member

I'm going to make the following API changes:

Shared Stores

  1. We allow defining the redux store in the controller, before the view renders. We can use the same api:

    redux_store(store_name, props = {})
  2. We provide a new helper redux_store_hydration_data which takes no parameters. This client renders the redux store registered at the controller level. Put at end of your layout so that browser is not blocked reading your props for client side hydration. I.e., the browser can render your server rendered React before trying to parse props. Best to place this on your main Rails layout. This generates nothing if there's no stores being initialized by the controller. Note, while multiple stores would be rendered, a best practice is to have only one store.

    redux_store_hydration_data
  3. Allow calling getStore to return undefined

    # Add optional parameter to getStore to not throw if store is not found
    ReactOnRails.getStore(storeName, required = true);
@justin808 justin808 self-assigned this Mar 5, 2016
@justin808 justin808 added this to the 3.1 milestone Mar 5, 2016
@justin808
Copy link
Member Author

This will be better for performance because the store is defined in the controller (for server rendering), and we can render the dom element with the store for the page updated callback at the very end of the page dom.

@justin808
Copy link
Member Author

Instead of render_redux_stores:

redux_store_hydration_data ==> put at end of your layout so that browser is not blocked reading your props for client side hydration. I.e., the browser can render your server rendered React before trying to parse props.

Discussing with @robwise...

@justin808
Copy link
Member Author

Started: #311.

CC: @robwise

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant