Module: ReactOnRails::Controller
- Defined in:
- lib/react_on_rails/controller.rb,
lib/react_on_rails/controller/form_responders.rb,
sig/react_on_rails/controller.rbs,
sig/react_on_rails/controller/form_responders.rbs
Defined Under Namespace
Modules: FormResponders
Instance Method Summary collapse
-
#redux_store(store_name, props: {}, **rest) ⇒ Object
Separate initialization of store from react_component allows multiple react_component calls to use the same Redux store.
-
#redux_store_hydration_data ⇒ safe_buffer
Returns html_safe string (ActiveSupport::SafeBuffer).
Instance Method Details
#redux_store(store_name, props: {}, **rest) ⇒ Object
Separate initialization of store from react_component allows multiple react_component calls to use the same Redux store.
store_name: name of the store, corresponding to your call to ReactOnRails.registerStores in your JavaScript code. props: Named parameter props which is a Ruby Hash or JSON string which contains the properties to pass to the redux store.
Be sure to include view helper redux_store_hydration_data at the end of your layout or view
or else there will be no client side hydration of your stores.
17 18 19 20 21 22 23 24 |
# File 'lib/react_on_rails/controller.rb', line 17 def redux_store(store_name, props: {}, **rest) ReactOnRails::Helper.(rest) redux_store_data = { store_name:, props: } @registered_stores_defer_render ||= [] @registered_stores_defer_render << redux_store_data end |
#redux_store_hydration_data ⇒ safe_buffer
Returns html_safe string (ActiveSupport::SafeBuffer)
12 |
# File 'sig/react_on_rails/controller.rbs', line 12
def redux_store_hydration_data: () -> safe_buffer
|