Skip to content

Issue with SSR when using Rails & React #378

@svetliomihailov

Description

@svetliomihailov

Hello, thank you very much for creating & maintaining this library!
It's awesome and I use it in all of my projects at work :)

I'm having an issue with Server side rendering with the latest versions.
The problem first shows up in version 1.1.3. In version 1.1.2 the issue is not present.

Steps to reproduce the behavior:

Here is a repo with an example Rails project. The steps to run the project and reproduce the issue are in the README file.

Expected behavior:

To be able to see the rendered component

Actual behavior:

The result is the following error:

Encountered error "#<ExecJS::ProgramError: Error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined. You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.>" when prerendering Gallery with {}
ReactDOMServerRenderer.render ((execjs):10837:21)
ReactDOMServerRenderer.read ((execjs):10488:33)
Object.renderToString ((execjs):11071:31)
Object.serverRender ((execjs):48838:42)
eval (eval at <anonymous> ((execjs):52906:8), <anonymous>:6:45)
eval (eval at <anonymous> ((execjs):52906:8), <anonymous>:18:13)
(execjs):52906:8
(execjs):52912:14
(execjs):1:40
Object.<anonymous> ((execjs):1:58)
/Users/svetlio/.asdf/installs/ruby/2.7.1/lib/ruby/gems/2.7.0/gems/execjs-2.7.0/lib/execjs/external_runtime.rb:39:in `exec'
/Users/svetlio/.asdf/installs/ruby/2.7.1/lib/ruby/gems/2.7.0/gems/execjs-2.7.0/lib/execjs/external_runtime.rb:21:in `eval'
/Users/svetlio/.asdf/installs/ruby/2.7.1/lib/ruby/gems/2.7.0/gems/react-rails-2.6.1/lib/react/server_rendering/exec_js_renderer.rb:39:in `render_from_parts'
/Users/svetlio/.asdf/installs/ruby/2.7.1/lib/ruby/gems/2.7.0/gems/react-rails-2.6.1/lib/react/server_rendering/exec_js_renderer.rb:20:in `render'

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions