danistefanovic / react-lazy-hero

⚡️ A hero component for React

Home Page:http://react-lazy-hero.danielstefanovic.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

SSR Support

clodal opened this issue · comments

Any chance if server-side rendering is supported via styled-components?

TypeError: styleSheet.getName is not a function
    at ComponentStyle.generateAndInjectStyles (/Users/clodal/sites/abc/node_modules/react-lazy-hero/node_modules/styled-components/lib/models/ComponentStyle.js:95:37)
    at StyledComponent.generateAndInjectStyles (/Users/clodal/sites/abc/node_modules/react-lazy-hero/node_modules/styled-components/lib/models/StyledComponent.js:154:40)
    at StyledComponent.componentWillMount (/Users/clodal/sites/abc/node_modules/react-lazy-hero/node_modules/styled-components/lib/models/StyledComponent.js:192:40)
    at processChild (/Users/clodal/sites/abc/packages/server/node_modules/react-dom/cjs/react-dom-server.node.development.js:2167:16)
    at resolve (/Users/clodal/sites/abc/packages/server/node_modules/react-dom/cjs/react-dom-server.node.development.js:2061:5)
    at ReactDOMServerRenderer.render (/Users/clodal/sites/abc/packages/server/node_modules/react-dom/cjs/react-dom-server.node.development.js:2380:22)
    at ReactDOMServerRenderer.read (/Users/clodal/sites/abc/packages/server/node_modules/react-dom/cjs/react-dom-server.node.development.js:2354:19)
    at Object.renderToString (/Users/clodal/sites/abc/packages/server/node_modules/react-dom/cjs/react-dom-server.node.development.js:2726:25)
    at /Users/clodal/sites/abc/packages/server/build/index.js:56:257515
    at tryCatch (/Users/clodal/sites/abc/node_modules/babel-runtime/node_modules/regenerator-runtime/runtime.js:62:40)
    at Generator.invoke [as _invoke] (/Users/clodal/sites/abc/node_modules/babel-runtime/node_modules/regenerator-runtime/runtime.js:296:22)
    at Generator.prototype.(anonymous function) [as next] (/Users/clodal/sites/abc/node_modules/babel-runtime/node_modules/regenerator-runtime/runtime.js:114:21)
    at step (/Users/clodal/sites/abc/node_modules/babel-runtime/helpers/asyncToGenerator.js:17:30)
    at /Users/clodal/sites/abc/node_modules/babel-runtime/helpers/asyncToGenerator.js:28:13
    at <anonymous>

Can you provide a repo for reproduction?

I've made a repo for repro and actually found the error was due to having duplicated versions of styled-components

➜  apollo-universal-starter-kit git:(add-react-lazy-hero) ✗ yarn list styled-components
yarn list v1.7.0
warning Filtering by arguments is deprecated. Please use the pattern option instead.
├─ react-lazy-hero@0.4.0
│  └─ styled-components@2.4.1 // <<< dupe 
└─ styled-components@3.4.5 // <<< dupe

Any chance we can move react-lazy-hero's styled-components dep to a peer dep?
https://www.styled-components.com/docs/faqs#i-am-a-library-author-should-i-bundle-styledcomponents-with-my-library

Happy to PR

Thanks for the PR! v1.0.0 is published.