VerticalDivider for PageLayout.Pane always initially renders as style 'none' #3331
Labels
bug
Something isn't working
component: SplitPageLayout
Issues related to the PageLayout and SplitPageLayout components
react
Stale
Description
I'm using React Router to render several different pages that are laid out almost identically. They generally look like this:
Each route renders a component with the same
PageLayout.pane
with a 'line' divider. When I switch routes, most of the DOM appears stable to my eyes, but there's a brief period where the vertical divider seems to disappear.I investigated and found that this happens on initial render, and that I could recreate it via the storybook locally. In the video below I've set a breakpoint when the
VerticalDivider
renders. You'll see that in the first few renders, the divider doesn't show at all. On the third render it pops into view as a line the way I'd expect.pagelayout-divider-rerenders.mp4
From the React devtools profiler , the
VerticalDivider
renders a total of 4 times. On the third render it finally becomes visible.I set a logpoint in the
PageLayout.Pane
component to record its props over its renders. You'll see theresponsiveVariant
value changes fromnone
toline
. Each logpoint shows up twice since we're in strict mode.This corresponds to the
useMedia()
hooks used byuseResponsiveValue()
going fromfalse
totrue
.Under the hood
useResponsiveValue()
callsuseMedia()
with a defaultState value offalse
for all three viewport widthsreact/src/hooks/useResponsiveValue.ts
Lines 52 to 54 in 1fd6d32
and this basically forces us to return the
fallback
value on initial render, which isnone
for theVerticalDivider
.If I modify
useResponsiveValue
so that it doesn't pass a default, like this:The component initially renders as I'd expect. Would a change like this be possible or will it create problems for SSR? I see this comment:
react/src/hooks/useMedia.tsx
Lines 25 to 28 in 1fd6d32
Steps to reproduce
/?path=/story/components-pagelayout--default
Pane.divider.regular
to beline
Version
v35.25.1
Browser
Chrome
The text was updated successfully, but these errors were encountered: