Skip to content

Commit

Permalink
Fix lazy browser styles (#107)
Browse files Browse the repository at this point in the history
* Fix issue with duplicated and conflicting styles in lazy hydrated components

* bump version
  • Loading branch information
markbrocato authored Jun 15, 2020
1 parent cec56c0 commit bae3842
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-storefront",
"version": "8.10.1",
"version": "8.10.2",
"description": "Build and deploy e-commerce progressive web apps (PWAs) in record time.",
"module": "./index.js",
"license": "Apache-2.0",
Expand Down
8 changes: 6 additions & 2 deletions src/LazyHydrate.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export function LazyStyles() {

function LazyStylesProvider({ id, children }) {
const generateClassName = createGenerateClassName({
productionPrefix: `lazy-${id}`,
seed: id,
})
const registry = new SheetsRegistry()
registry.id = id
Expand Down Expand Up @@ -211,7 +211,11 @@ function LazyHydrateInstance({ id, className, ssrOnly, children, on, ...props })
function LazyHydrate({ children, ...props }) {
return (
<LazyHydrateInstance {...props}>
<LazyStylesProvider {...props}>{children}</LazyStylesProvider>
{/* LazyStylesProvider should not be used in the browser. Once components
are hydrated, their styles will automatically be managed by the app's main
StyleProvider. Using LazyStylesProvider in the browser will result in duplicated
and conflicting styles in lazy components once they are hydrated. */}
{isBrowser() ? children : <LazyStylesProvider {...props}>{children}</LazyStylesProvider>}
</LazyHydrateInstance>
)
}
Expand Down

0 comments on commit bae3842

Please sign in to comment.