Invariant Violation in Server-Side Rendering after import css styles
See original GitHub issueSteps to reproduce
New rails project with webpacker 4.0.0.rc.7 and react-rails from github (master). Only one component:
import React, { Component } from 'react'
import styles from './App.module.css'
class App extends Component {
render () {
return (
<div className={styles.root}>
APP
</div>
);
}
}
export default App
In view: <%= react_component('App', {}, { prerender: true }) %>
Expected behavior
Prerender html and working fine in browser.
Actual behavior
Encountered error “#<ExecJS::ProgramError: Invariant Violation: 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 App with {}
System configuration
Webpacker version: 4.0.0.rc.7 React-Rails version: master from github Rails version: 5.2.2 Ruby version: 2.6.0
If disable prerender everything working fine. If remove import styles
and all styles from className too. I don’t need styles for prerender, maybe I must disable it for ssr? But how?
Issue Analytics
- State:
- Created 5 years ago
- Comments:12
Top GitHub Comments
I found a solution:
It’s works fine with webpacker 3.5.5. Problem only with 4.x version.