From 91ef0f960b7f75619e43c63975aa9ce59b17c9ca Mon Sep 17 00:00:00 2001 From: Alexey Mahotkin Date: Wed, 18 Jul 2018 23:30:02 +0200 Subject: [PATCH] Always clear hydrated stores inside the server-side rendering worker --- lib/react_on_rails/helper.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/react_on_rails/helper.rb b/lib/react_on_rails/helper.rb index 765ab6703..aa76a783a 100644 --- a/lib/react_on_rails/helper.rb +++ b/lib/react_on_rails/helper.rb @@ -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])