You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
run the hook-components.js test (near the bottom of the list)
the tests for BreakpointNumbers should fail
Current behavior:
BreakpointNumber, which uses useResponsiveValue, is always falling back to the default value of 0. It never uses the intended custom breakpoints names and values.
createWithBreakpoints is logging a warning in the console, saying that the custom breakpoint names are not found, and listing the default breakpoints as being available.
Expected behavior:
BreakpointNumber should show 0 on small screens, 1 on medium screens, 2 on large screens
Environment:
node version: 14.15.4
npm version: 7.6.0
atomic-layout version: ^0.16.2
Current Pointers:
Console logging inside of the Layout.configure and createWithBreakpoints functions have shown that createWithBreakpoints is being called before Layout.configure, therefore it uses the default breakpoints. After Layout.configure is called, createWithBreakpoints and useResponsiveValue do not receive the latest breakpoint objects.
Screenshots:
The console logging output, showing createWithBreakpoints before Layout.configure:
Warning from createWithBreakpoints:
Visuals from cypress, showing the responsive value always at the default of 0:
The text was updated successfully, but these errors were encountered:
As a workaround, I wrote this hook for myself, it has the same API as the one that isn't working currently:
import{useState}from'react';importLayout,{useViewportChange}from'atomic-layout';exportdefault({ to, from })=>{const[matches,setMatches]=useState(false);useViewportChange(()=>{setMatches((typeofto==='undefined'||window.innerWidth<Layout.breakpoints[to].maxWidth)&&(typeoffrom==='undefined'||window.innerWidth>Layout.breakpoints[from].minWidth));});returnmatches;};
When:
This issue came up in a react-static setup.
yarn start
yarn cypress open
hook-components.js
test (near the bottom of the list)Current behavior:
BreakpointNumber, which uses useResponsiveValue, is always falling back to the default value of 0. It never uses the intended custom breakpoints names and values.
createWithBreakpoints
is logging a warning in the console, saying that the custom breakpoint names are not found, and listing the default breakpoints as being available.Expected behavior:
BreakpointNumber should show 0 on
small
screens, 1 onmedium
screens, 2 onlarge
screensEnvironment:
14.15.4
7.6.0
^0.16.2
Current Pointers:
Console logging inside of the
Layout.configure
andcreateWithBreakpoints
functions have shown thatcreateWithBreakpoints
is being called beforeLayout.configure
, therefore it uses the default breakpoints. AfterLayout.configure
is called,createWithBreakpoints
anduseResponsiveValue
do not receive the latest breakpoint objects.Screenshots:
The console logging output, showing
createWithBreakpoints
beforeLayout.configure
:Warning from
createWithBreakpoints
:Visuals from cypress, showing the responsive value always at the default of 0:
The text was updated successfully, but these errors were encountered: