-
Notifications
You must be signed in to change notification settings - Fork 188
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
BpkBreakpoint: Fix Server Side Rendering (#3299)
* BpkBreakpoint: Fix & Optimize SSR rendering * small tweak to useMediaQuery + fix tests * Re-add snapshot * Remove isClient block within useMediaQuery useEffect * mock useMediaQuery in tests * remove console log * Add to readme * Improve guidance * Update type and README * Small correction to guidance snipper * Add dummy import * Removed isClient from dependency array
- Loading branch information
Showing
13 changed files
with
199 additions
and
116 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 8 additions & 14 deletions
22
packages/bpk-component-breakpoint/src/__snapshots__/BpkBreakpoint-test.tsx.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,27 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`BpkBreakpoint SSR mode should not render on SSR until hydrated when matchSSR=false: hydrated 1`] = ` | ||
exports[`BpkBreakpoint children as a callback function should call function with matches=false if the breakpoint is not matched 1`] = ` | ||
<DocumentFragment> | ||
<div | ||
data-reactroot="" | ||
> | ||
matches | ||
<div> | ||
does not match | ||
</div> | ||
</DocumentFragment> | ||
`; | ||
|
||
exports[`BpkBreakpoint SSR mode should not render on SSR until hydrated when matchSSR=false: server rendered 1`] = `"<div data-reactroot="">does not match</div>"`; | ||
|
||
exports[`BpkBreakpoint SSR mode should not render when matchSSR is not defined 1`] = `"<div data-reactroot="">does not match</div>"`; | ||
|
||
exports[`BpkBreakpoint SSR mode should render when matchSSR=true 1`] = `"<div data-reactroot="">matches</div>"`; | ||
|
||
exports[`BpkBreakpoint should render if the breakpoint is matched 1`] = ` | ||
exports[`BpkBreakpoint children as a callback function should call function with matches=true if the breakpoint is matched 1`] = ` | ||
<DocumentFragment> | ||
<div> | ||
matches | ||
</div> | ||
</DocumentFragment> | ||
`; | ||
|
||
exports[`BpkBreakpoint should render if the breakpoint is not matched 1`] = ` | ||
exports[`BpkBreakpoint children as component should not render when breakpoint does not match 1`] = `<DocumentFragment />`; | ||
|
||
exports[`BpkBreakpoint children as component should render when breakpoint matches 1`] = ` | ||
<DocumentFragment> | ||
<div> | ||
does not match | ||
matches | ||
</div> | ||
</DocumentFragment> | ||
`; |
7 changes: 7 additions & 0 deletions
7
packages/bpk-component-breakpoint/src/__snapshots__/useMediaQuery-test.tsx.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`useMediaQuery SSR mode should match when matchSSR=true 1`] = `"<div data-reactroot="">matches</div>"`; | ||
|
||
exports[`useMediaQuery SSR mode should not match when matchSSR not explicitly set 1`] = `"<div data-reactroot="">no match</div>"`; | ||
|
||
exports[`useMediaQuery SSR mode should not match when matchSSR=false 1`] = `"<div data-reactroot="">no match</div>"`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.