Skip to content

Commit

Permalink
Always clear hydrated stores inside the server-side rendering worker
Browse files Browse the repository at this point in the history
  • Loading branch information
squadette authored and justin808 committed Jul 23, 2018
1 parent 4888642 commit 91ef0f9
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/react_on_rails/helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -472,14 +472,14 @@ def server_rendered_react_component(render_options)
end

def initialize_redux_stores
return "" unless @registered_stores.present? || @registered_stores_defer_render.present?
declarations = "var reduxProps, store, storeGenerator;\n".dup
all_stores = (@registered_stores || []) + (@registered_stores_defer_render || [])

result = <<-JS.dup
ReactOnRails.clearHydratedStores();
JS

return result unless @registered_stores.present? || @registered_stores_defer_render.present?
declarations = "var reduxProps, store, storeGenerator;\n".dup
all_stores = (@registered_stores || []) + (@registered_stores_defer_render || [])

result << all_stores.each_with_object(declarations) do |redux_store_data, memo|
store_name = redux_store_data[:store_name]
props = props_string(redux_store_data[:props])
Expand Down

0 comments on commit 91ef0f9

Please sign in to comment.