File tree Expand file tree Collapse file tree 2 files changed +21
-3
lines changed Expand file tree Collapse file tree 2 files changed +21
-3
lines changed Original file line number Diff line number Diff 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
142160This library is (luckily) not a reimplementation from scratch of
Original file line number Diff line number Diff line change 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" ,
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}
You can’t perform that action at this time.
0 commit comments