Skip to content

Commit cea9819

Browse files
committed
Add note for optional styled-components dependency
Fix #13
1 parent 5cf61c9 commit cea9819

File tree

2 files changed

+21
-3
lines changed

2 files changed

+21
-3
lines changed

README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,24 @@ already, `ssrPrepass` will suspend on `<Query>` components.
137137

138138
[More information can be found in Apollo's own docs](https://www.apollographql.com/docs/react/features/server-side-rendering.html#getDataFromTree)
139139

140+
## Optional Dependencies
141+
142+
### Special case for `styled-components`
143+
144+
`react-ssr-prepass` has an optional dependency on `styled-components@>=4.0.0`.
145+
This optimization skips any styling logic and imitates the attributes and props
146+
logic of `styled-components` otherwise.
147+
148+
It exists because styled-components may populate the `ServerStyleSheet` as
149+
part of a `react-ssr-prepass` run, since it behaves like a normal React renderer.
150+
This is dangerous if the element tree that is passed to `react-ssr-prepass`
151+
is not wrapped in a `ServerStyleSheet` at all, since it will start accumulating
152+
styles and cause a memory leak. In `v4` it can also cause these styles to
153+
become _global_ and be sent to every server-rendered page.
154+
155+
If you're not using styled-components however and are bundling your server-side
156+
code you need to stub styled-components with an empty package or just install it.
157+
140158
## Prior Art
141159

142160
This library is (luckily) not a reimplementation from scratch of

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,9 @@
6060
"react": "^16.8.0",
6161
"react-is": "^16.8.0"
6262
},
63+
"dependencies": {
64+
"object-is": "^1.0.1"
65+
},
6366
"devDependencies": {
6467
"@babel/core": "^7.3.4",
6568
"@babel/preset-env": "^7.3.4",
@@ -77,8 +80,5 @@
7780
"react-dom": "^16.8.4",
7881
"react-is": "^16.8.4",
7982
"styled-components": "^4.2.0"
80-
},
81-
"dependencies": {
82-
"object-is": "^1.0.1"
8383
}
8484
}

0 commit comments

Comments
 (0)