lib/react/rails/railtie.rb in react-rails-2.2.0 vs lib/react/rails/railtie.rb in react-rails-2.2.1

- old
+ new

@@ -22,21 +22,25 @@ config.react.server_renderer_extensions = ["jsx", "js"] # View helper implementation: config.react.view_helper_implementation = nil # Defaults to ComponentMount # Watch .jsx files for changes in dev, so we can reload the JS VMs with the new JS code. - initializer "react_rails.add_watchable_files", group: :all do |app| + initializer "react_rails.add_watchable_files", after: :load_config_initializers, group: :all do |app| # Watch files ending in `server_renderer_extensions` in each of `server_renderer_directories` reload_paths = config.react.server_renderer_directories.reduce({}) do |memo, dir| app_dir = File.join(app.root, dir) memo[app_dir] = config.react.server_renderer_extensions memo end # Rails checks these objects for changes: - app.reloaders << app.config.file_watcher.new([], reload_paths) {} + react_reloader = app.config.file_watcher.new([], reload_paths) do + React::ServerRendering.reset_pool + end + app.reloaders << react_reloader + # Reload renderers in dev when files change - config.to_prepare { React::ServerRendering.reset_pool } + config.to_prepare { react_reloader.execute_if_updated } end # Include the react-rails view helper lazily initializer "react_rails.setup_view_helpers", after: :load_config_initializers, group: :all do |app|