This repository was archived by the owner on Oct 1, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 6 files changed +21
-14
lines changed
Expand file tree Collapse file tree 6 files changed +21
-14
lines changed Original file line number Diff line number Diff line change @@ -14,13 +14,14 @@ export default function Article(props) {
1414 COMPONENTS . forEach ( Component => Component . stop ( ) )
1515 }
1616
17+ const onMountOnly = [ ]
1718 useEffect ( ( ) => {
1819 Prism . highlightAll ( )
1920 COMPONENTS . forEach ( Component => Component . start ( ) )
2021 setDomIsLoaded ( true )
2122
2223 return componentUnmountFunction
23- } , [ ] )
24+ } , onMountOnly )
2425
2526 return (
2627 < article
Original file line number Diff line number Diff line change 1- import React , { createRef , useState , useEffect } from "react"
1+ import React , { useRef , useState , useEffect } from "react"
22import { withLastLocation } from "react-router-last-location"
33import PropTypes from "prop-types"
44
55import { FOCUSABLE_TABINDEX , UNFOCUSABLE_TABINDEX } from "./constants"
66
77const PageHeader = props => {
88 const [ tabIndex , setTabIndex ] = useState ( FOCUSABLE_TABINDEX )
9- const headerRef = createRef ( )
9+ const headerRef = useRef ( null )
10+ const onMountOnly = [ ]
1011
1112 useEffect ( ( ) => {
1213 if ( props . lastLocation ) {
1314 headerRef . current . focus ( )
1415 } else {
1516 setTabIndex ( UNFOCUSABLE_TABINDEX )
1617 }
17- } , [ ] )
18+ } , onMountOnly )
1819
1920 const handleBlur = ( ) => {
2021 if ( tabIndex === UNFOCUSABLE_TABINDEX ) return
Original file line number Diff line number Diff line change 11import { useEffect } from "react"
22
33export default function ScrollUpOnMount ( ) {
4+ const onMountOnly = [ ]
5+
46 useEffect ( ( ) => {
57 window . scrollTo ( 0 , 0 )
6- } , [ ] )
8+ } , onMountOnly )
79
810 return null
911}
Original file line number Diff line number Diff line change @@ -33,18 +33,20 @@ export default function SideNav() {
3333 Accordions . stop ( )
3434 }
3535
36+ const onMountOnly = [ ]
3637 useEffect ( ( ) => {
3738 Accordions . start ( )
3839 window . addEventListener ( "resize" , handleMenuVisibility )
3940 setMenuIsOpen ( isLargerThanCollapseWidth )
4041
4142 return componentUnmountFunction
42- } , [ ] )
43+ } , onMountOnly )
4344
45+ const updateConditions = [ menuIsOpen ]
4446 useEffect ( ( ) => {
4547 Accordions . stop ( )
4648 Accordions . start ( )
47- } , [ menuIsOpen ] )
49+ } , updateConditions )
4850
4951 // set up handlers and other helper methods
5052
Original file line number Diff line number Diff line change @@ -14,29 +14,29 @@ import "./styles.scss"
1414import { FOCUSABLE_TABINDEX , UNFOCUSABLE_TABINDEX } from "./constants"
1515
1616export default function Main ( ) {
17+ const headerRef = React . useRef ( null )
18+ const mainRef = React . useRef ( null )
1719 const Attributes = {
1820 TABINDEX : "tabindex" ,
1921 }
22+ const getHeaderTabIndex = ( ) => headerRef . current . getAttribute ( Attributes . TABINDEX )
23+ const getMainTabIndex = ( ) => mainRef . current . getAttribute ( Attributes . TABINDEX )
2024
21- const headerRef = React . createRef ( )
22- const mainRef = React . createRef ( )
2325 const componentUnmountFunction = ( ) => {
2426 ContextUtil . disableFocusOutline ( )
2527 }
2628
29+ const onMountOnly = [ ]
2730 useEffect ( ( ) => {
2831 ContextUtil . enableFocusOutline ( )
2932 return componentUnmountFunction
30- } , [ ] )
33+ } , onMountOnly )
3134
3235 const handleRefocusClick = ref => {
3336 ref . current . setAttribute ( Attributes . TABINDEX , FOCUSABLE_TABINDEX )
3437 ref . current . focus ( )
3538 }
3639
37- const getHeaderTabIndex = ( ) => headerRef . current . getAttribute ( Attributes . TABINDEX )
38- const getMainTabIndex = ( ) => mainRef . current . getAttribute ( Attributes . TABINDEX )
39-
4040 const handleHeaderBlur = ( ) => {
4141 if ( getHeaderTabIndex ( ) === UNFOCUSABLE_TABINDEX ) return
4242 headerRef . current . removeAttribute ( Attributes . TABINDEX )
Original file line number Diff line number Diff line change @@ -41,12 +41,13 @@ export default function Home() {
4141 ANIMATION_DATA . forEach ( instance => instance . animation . destroy ( ) )
4242 }
4343
44+ const onMountOnly = [ ]
4445 useEffect ( ( ) => {
4546 Prism . highlightAll ( )
4647 loadAnimations ( )
4748
4849 return componentUnmountFunction
49- } , [ ] )
50+ } , onMountOnly )
5051
5152 const renderAnimations = ( ) => {
5253 return ANIMATION_DATA . map ( animation => {
You can’t perform that action at this time.
0 commit comments