Skip to content

API Changes #309

Closed
Closed
@justin808

Description

@justin808

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);

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions