GithubHelp home page GithubHelp logo

Comments (3)

mdesantis avatar mdesantis commented on June 14, 2024 1

@ahangarha you're right; specifically, I skipped the part in which it says:

Requires separate compilations for server & client bundles (see Webpack config)

I didn't get I had to check it and copy the files. Now I have another error, but it's unrelated. Thanks!

from react-rails.

mdesantis avatar mdesantis commented on June 14, 2024

I could fix it creating an initializer with this contents:

class MyAssetContainer
  def find_asset(filename)
    asset_path = Shakapacker.config.public_output_path.join('js', filename).to_s
    File.read(asset_path)
  end
end

React::ServerRendering::BundleRenderer.asset_container_class = MyAssetContainer

But now I get another error, unfortunately not as trivial as the previous one:

React::ServerRendering::PrerenderError in HelloWorld#hello_world_1

Showing /app/views/hello_world/hello_world_1.html.erb where line #2 raised:

Encountered error "#<ExecJS::ProgramError: TypeError: Cannot read properties of undefined (reading 'serverRender')>" when prerendering HelloWorld with {"greeting":"Hello from react-rails."}
eval (eval at <anonymous> ((execjs):116:8), <anonymous>:6:45)
eval (eval at <anonymous> ((execjs):116:8), <anonymous>:18:13)
(execjs):116:8
(execjs):134:14
(execjs):1:32
Object.<anonymous> ((execjs):1:50)
Module._compile (node:internal/modules/cjs/loader:1256:14)
Module._extensions..js (node:internal/modules/cjs/loader:1310:10)
Module.load (node:internal/modules/cjs/loader:1119:32)
Module._load (node:internal/modules/cjs/loader:960:12)
/gems/execjs-2.9.1/lib/execjs/external_runtime.rb:40:in `exec'
/gems/execjs-2.9.1/lib/execjs/external_runtime.rb:22:in `eval'
/gems/react-rails-3.1.1/lib/react/server_rendering/exec_js_renderer.rb:48:in `render_from_parts'
/gems/react-rails-3.1.1/lib/react/server_rendering/exec_js_renderer.rb:24:in `render'
/gems/react-rails-3.1.1/lib/react/server_rendering/bundle_renderer.rb:42:in `render'
/gems/react-rails-3.1.1/lib/react/server_rendering.rb:29:in `block in render'
/gems/connection_pool-2.4.1/lib/connection_pool.rb:110:in `block (2 levels) in with'
/gems/connection_pool-2.4.1/lib/connection_pool.rb:109:in `handle_interrupt'
/gems/connection_pool-2.4.1/lib/connection_pool.rb:109:in `block in with'
/gems/connection_pool-2.4.1/lib/connection_pool.rb:106:in `handle_interrupt'
/gems/connection_pool-2.4.1/lib/connection_pool.rb:106:in `with'
/gems/react-rails-3.1.1/lib/react/server_rendering.rb:28:in `render'
/gems/react-rails-3.1.1/lib/react/rails/component_mount.rb:50:in `prerender_component'
/gems/react-rails-3.1.1/lib/react/rails/component_mount.rb:37:in `block in react_component'
/gems/actionview-7.1.2/lib/action_view/helpers/capture_helper.rb:50:in `block in capture'
/gems/actionview-7.1.2/lib/action_view/buffers.rb:75:in `capture'
/gems/actionview-7.1.2/lib/action_view/helpers/capture_helper.rb:50:in `capture'
/gems/actionview-7.1.2/lib/action_view/helpers/tag_helper.rb:349:in `content_tag'
/gems/react-rails-3.1.1/lib/react/rails/component_mount.rb:76:in `rendered_tag'
/gems/react-rails-3.1.1/lib/react/rails/component_mount.rb:41:in `react_component'
/gems/react-rails-3.1.1/lib/react/rails/view_helper.rb:23:in `react_component'
/app/views/hello_world/hello_world_1.html.erb:2:in `_app_views_hello_world_hello_world___html_erb__2374411509695113706_19720'

from react-rails.

ahangarha avatar ahangarha commented on June 14, 2024

Did you follow https://github.com/reactjs/react-rails#server-side-rendering to create separate webpack config for client and server-side rendering?

from react-rails.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.