Skip to content

Commit bae3842

Browse files
authored
Fix lazy browser styles (#107)
* Fix issue with duplicated and conflicting styles in lazy hydrated components * bump version
1 parent cec56c0 commit bae3842

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-storefront",
3-
"version": "8.10.1",
3+
"version": "8.10.2",
44
"description": "Build and deploy e-commerce progressive web apps (PWAs) in record time.",
55
"module": "./index.js",
66
"license": "Apache-2.0",

src/LazyHydrate.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ export function LazyStyles() {
6666

6767
function LazyStylesProvider({ id, children }) {
6868
const generateClassName = createGenerateClassName({
69-
productionPrefix: `lazy-${id}`,
69+
seed: id,
7070
})
7171
const registry = new SheetsRegistry()
7272
registry.id = id
@@ -211,7 +211,11 @@ function LazyHydrateInstance({ id, className, ssrOnly, children, on, ...props })
211211
function LazyHydrate({ children, ...props }) {
212212
return (
213213
<LazyHydrateInstance {...props}>
214-
<LazyStylesProvider {...props}>{children}</LazyStylesProvider>
214+
{/* LazyStylesProvider should not be used in the browser. Once components
215+
are hydrated, their styles will automatically be managed by the app's main
216+
StyleProvider. Using LazyStylesProvider in the browser will result in duplicated
217+
and conflicting styles in lazy components once they are hydrated. */}
218+
{isBrowser() ? children : <LazyStylesProvider {...props}>{children}</LazyStylesProvider>}
215219
</LazyHydrateInstance>
216220
)
217221
}

0 commit comments

Comments
 (0)