Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/healthy-icons-build.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@primer/react': patch
---

Update useStickyPaneHeight and useMedia to not warn during SSR
3 changes: 2 additions & 1 deletion src/PageLayout/useStickyPaneHeight.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React from 'react'
import {useInView} from 'react-intersection-observer'
import {canUseDOM} from '../utils/environment'
import useLayoutEffect from '../utils/useIsomorphicLayoutEffect'

/**
* Calculates the height of the sticky pane such that it always
Expand Down Expand Up @@ -49,7 +50,7 @@ export function useStickyPaneHeight() {
// if the pane is sticky.
const [isEnabled, setIsEnabled] = React.useState(false)

React.useLayoutEffect(() => {
useLayoutEffect(() => {
const scrollContainer = getScrollContainer(rootRef.current)

if (isEnabled && (contentTopInView || contentBottomInView)) {
Expand Down
6 changes: 3 additions & 3 deletions src/hooks/useResponsiveValue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ export function isResponsiveValue(value: any): value is ResponsiveValue<any> {
export function useResponsiveValue<T, F>(value: T, fallback: F): FlattenResponsiveValue<T> | F {
// Check viewport size
// TODO: What is the performance cost of creating media query listeners in this hook?
const isNarrowViewport = useMedia(viewportRanges.narrow)
const isRegularViewport = useMedia(viewportRanges.regular)
const isWideViewport = useMedia(viewportRanges.wide)
const isNarrowViewport = useMedia(viewportRanges.narrow, false)
const isRegularViewport = useMedia(viewportRanges.regular, false)
const isWideViewport = useMedia(viewportRanges.wide, false)

if (isResponsiveValue(value)) {
// If we've reached this line, we know that value is a responsive value
Expand Down