Comments (3)
@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.
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.
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)
- Update to React 18 for embedded React HOT 2
- Server side rendering broken in 2.7 HOT 2
- `ReactDOM.version?.split` not transpiled? HOT 3
- Can't resolve 'react-dom/client' HOT 3
- Import react_component but it' shown HOT 2
- compare/contrast and migration steps to react_on_rails HOT 5
- Component doesn't render on jsbundling-rails webpacker HOT 5
- Component not loading in rails app HOT 5
- react-rails v3.1.0 is broken HOT 1
- server_rendering.js not found following README HOT 8
- Re-organize documentations in docs folder
- server_rendering.js not found following README HOT 1
- How do I handle styling?
- esbuild HOT 1
- Setup StrictMode for components HOT 2
- get started docs r-r version HOT 1
- Rails 7.1 Renders Partial Header HOT 1
- Server side rendering `window` behaves differently than Node.js? HOT 4
- Issues with Loading React Component for Cuprite in Rails 7.1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-rails.