chore(docs): fix page-loaded class#4013
Conversation
|
@mcoker @wise-king-sullyman FYI pushed one additional change, to wrap this code in |
There was a problem hiding this comment.
Manually applied to my local dev server (until docs framework full page examples are fixed) - LGTM!
There was a problem hiding this comment.
I remember having some funky behavior when I tried using a useEffect for this in the initial approach, but I also didn't have the readyState check which I'm guessing resolves that issue since if it isn't done doing the initial paint when the effect runs it should add the listener, and when it is it should just load the class.
I do wonder if there might be an edge case here if the effect starts running before painting is complete, but not in time for the listener to catch the event, but we can always cross that bridge if/when we get there.
Towards #4009
This PR wraps the window.load listener in a check to see if the page has already completed loading before adding that listener (and if so, adds the page-loaded class).
mainbranch.