我有一个可用的 react-rails 应用程序,并且我一直在使用react_componentreact-rails 提供的帮助程序在 ERB 视图上开发一些新的反应视图。
我正在使用 SSR,因此:
<%= react_component("ProductApp", {locale: @locale, hotel: @hotel, slug: @product, area: @area, current_user: @current_user, csrf_token: form_authenticity_token }, {prerender: activate_ssr}) %>
事情是我现在得到:
ActionView::Template::Error: Encountered error "#<ExecJS::ProgramError: TypeError: Cannot read property 'registered' of null>" when prerendering ProductApp with {"locale":"es","hotel":"salles-hotel-pere-iv","slug":"circuito-de-spa-60-minutos-masaje-de-25-min","area":"barcelona","current_user":{"role":"admin","id":288682,"user_locale":"es","created_at":"2021-10-04T16:05:00.453Z","updated_at":"2022-02-23T19:27:50.090Z","provider":null,"uid":null,"image":null,"phone_number":null,"description":null,"admin":false,"gdpr":null,"phone":"3423434","manager_of":[],"coupon":null,"lastname":"prueba","birthday":null,"referral_code":"83f91d9c1ae3a0747fef3992e67e0c","referred_by_id":null,"referral_completed_at":null,"id_number":"31231331","province_id":147,"api_key":null,"connect_id":null},"csrf_token":"OpoHoCduKb8XHGNVIqcjEseWv77B6APxlIYA3T5l2GgesnR85XyI/JzF6uckdWaemXFSQeQ=="}
(execjs):36:1730383
Object.render ((execjs):36:923792)
e.t.render ((execjs):36:5287889)
e.t.read ((execjs):36:5286833)
Object.renderToString ((execjs):36:5292048)
Object.serverRender ((execjs):36:5271255)
eval (eval at <anonymous> ((execjs):38:8), <anonymous>:6:45)
eval (eval at <anonymous> ((execjs):38:8), <anonymous>:18:13)
(execjs):38:8
(execjs):56:14
/app/vendor/bundle/ruby/2.6.0/gems/execjs-2.8.1/lib/execjs/external_runtime.rb:39:in `exec'
/app/vendor/bundle/ruby/2.6.0/gems/execjs-2.8.1/lib/execjs/external_runtime.rb:21:in `eval'
/app/vendor/bundle/ruby/2.6.0/gems/react-rails-2.6.1/lib/react/server_rendering/exec_js_renderer.rb:39:in `render_from_parts'
/app/vendor/bundle/ruby/2.6.0/gems/react-rails-2.6.1/lib/react/server_rendering/exec_js_renderer.rb:20:in `render'
/app/vendor/bundle/ruby/2.6.0/gems/react-rails-2.6.1/lib/react/server_rendering/bundle_renderer.rb:40:in `render'
/app/vendor/bundle/ruby/2.6.0/gems/react-rails-2.6.1/lib/react/server_rendering.rb:27:in `block in render'
/app/vendor/bundle/ruby/2.6.0/gems/connection_pool-2.2.5/lib/connection_pool.rb:63:in `block (2 levels) in with'
/app/vendor/bundle/ruby/2.6.0/gems/connection_pool-2.2.5/lib/connection_pool.rb:62:in `handle_interrupt'
/app/vendor/bundle/ruby/2.6.0/gems/connection_pool-2.2.5/lib/connection_pool.rb:62:in `block in with'
/app/vendor/bundle/ruby/2.6.0/gems/connection_pool-2.2.5/lib/connection_pool.rb:59:in `handle_interrupt'
/app/vendor/bundle/ruby/2.6.0/gems/connection_pool-2.2.5/lib/connection_pool.rb:59:in `with'
/app/vendor/bundle/ruby/2.6.0/gems/react-rails-2.6.1/lib/react/server_rendering.rb:26:in `render'
错误突然出现。