Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

prerendering material-ui components #1152

Open
sternj opened this issue Dec 23, 2021 · 2 comments
Open

prerendering material-ui components #1152

sternj opened this issue Dec 23, 2021 · 2 comments

Comments

@sternj
Copy link

sternj commented Dec 23, 2021

I have been attempting to perform server-side rendering of mui (formerly material-ui) components and have been getting issues similar to #193. The precise error I am getting is

ActionView::Template::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 MaterialComponentList with {}

I was wondering whether the state of the art has changed with regards to using server-side rendering. For the sake of example, I am using a modified form of this in this gist

I'm on rails 6.1.4.4 with Ruby 3.0 and reasct-rails 2.6.1.

If it would be helpful I can spin up and post a minimal example.

@trostli
Copy link

trostli commented Jun 1, 2022

I have been seeing this as well. Unfortunately all I have been able to come up with is to avoid server-side rendering for the components that give me this error... I am wondering what the underlying cause is too
.

@alexisrabcarv
Copy link

alexisrabcarv commented Sep 25, 2023

I had that issue before, like the error states, you are passing in undefined when your prop expects a string or a function. Check your life cycle and all your variables to see which one get's inside undefined. Prerendering happens before viewing the page so window and document variables are undefined as well.

Also try to use functional components, class components are heavier and it could be causing the pre-render to fail.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants