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
defaultMatches bleeds through the initial render resulting in flashes of wrong state. replacing useEffect with useLayoutEffect would fix this but would require a workaround for server-side rendering
alternatively something like this could work
constmediaQueryList=useRef()constgetMediaQueryList=()=>window.matchMedia(typeofquery==='string' ? query : json2mq(query));letinitialMatches;if(typeofwindow!=='undefined'){mediaQueryList.current=getMediaQueryList();initialMatches=mediaQueryList.current.matches;}initialMatches=typeofinitialMatches!=='undefined' ? initialMatches : defaultMatches;const[matches,setMatches]=useState(initialMatches);useEffect(()=>{mediaQueryList.current=mediaQueryList.current||getMediaQueryList()// the rest of the method},[query])
what do you think?
The text was updated successfully, but these errors were encountered:
kingcons
added a commit
to kingcons/the-platform
that referenced
this issue
Jan 10, 2020
defaultMatches
bleeds through the initial render resulting in flashes of wrong state. replacinguseEffect
withuseLayoutEffect
would fix this but would require a workaround for server-side renderingalternatively something like this could work
what do you think?
The text was updated successfully, but these errors were encountered: