question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Preact X, Preact render to string & Styled Components

See original GitHub issue

Hey,

I’m trying to get styled-components@4.x to work with preact@10.0.0-alpha.2 and preact-render-to-string. But I’m always getting an error saying that react could not be found. Not sure if this is a bug or my configuration is wrong.

Steps:

  1. Check sandbox on https://codesandbox.io/s/ojv1j96739

Expected Result:

  • Renders h1 tag
  • Writes stylesheets into console

Actual Result:

Could not find dependency: ‘react’ relative to ‘/node_modules/styled-components/dist/styled-components.browser.cjs.js’

Styled Components Doc on SSR: https://www.styled-components.com/docs/advanced#server-side-rendering

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:1
  • Comments:10 (7 by maintainers)

github_iconTop GitHub Comments

2reactions
JoviDeCroockcommented, Mar 18, 2019

Have you got an entry in your webpack like this:

resolve: {
  alias: {
     react: 'preact/compat', // first try it with compat you can try preact after if it works
  }
}
1reaction
marvinhagemeistercommented, May 7, 2019

Just released preact-render-to-string@5.0.3 which includes support for the createContext-API 🎉

https://github.com/developit/preact-render-to-string/releases/tag/5.0.3

Read more comments on GitHub >

github_iconTop Results From Across the Web

Upgrading from Preact 8.x
This document is intended to guide you through upgrading an existing Preact 8.x application to Preact X and is divided in 3 main...
Read more >
preact-x-styled-components-ssr - CodeSandbox
CodeSandbox is an online editor tailored for web applications.
Read more >
Top 5 preact-render-to-string Code Examples | Snyk
To help you get started, we've selected a few preact-render-to-string examples, based on popular ways it is used in public projects. Secure your...
Read more >
Preact - Releases
Preact - ⚛️ Fast 3kB React alternative with the same modern API. Components & Virtual DOM. - Releases.
Read more >
preact-render-to-string - npm
Render JSX to an HTML string, with support for Preact components.. Latest version: 5.2.6, last published: 2 months ago.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found