1- import PropTypes from 'prop-types' ;
21import React , { useEffect , useRef , useState } from 'react' ;
32import { useDispatch , useSelector } from 'react-redux' ;
43import { useLocation } from 'react-router-dom' ;
54import { showReduxDevTools } from '../../store' ;
6- import DevTools from './components/DevTools' ;
5+ import { DevTools } from './components/DevTools' ;
76import { setPreviousPath } from '../IDE/actions/ide' ;
87import { setLanguage } from '../IDE/actions/preferences' ;
98import { CookieConsent } from '../User/components/CookieConsent' ;
9+ import type { RootState } from '../../reducers' ;
1010
11- function hideCookieConsent ( pathname ) {
11+ function hideCookieConsent ( pathname : string ) {
1212 if ( pathname . includes ( '/full/' ) || pathname . includes ( '/embed/' ) ) {
1313 return true ;
1414 }
1515 return false ;
1616}
1717
18- const App = ( { children } ) => {
18+ export const App = ( { children } : { children ?: React . ReactNode } ) => {
1919 const dispatch = useDispatch ( ) ;
2020
21- const location = useLocation ( ) ;
21+ const location = useLocation < { skipSavingPath ?: boolean } > ( ) ;
2222
23- const theme = useSelector ( ( state ) => state . preferences . theme ) ;
23+ const theme = useSelector ( ( state : RootState ) => state . preferences . theme ) ;
2424 useEffect ( ( ) => {
2525 document . body . className = theme ;
2626 } , [ theme ] ) ;
2727
2828 // TODO: this is only needed for the initial load and would be better handled elsewhere - Linda
29- const language = useSelector ( ( state ) => state . preferences . language ) ;
29+ const language = useSelector (
30+ ( state : RootState ) => state . preferences . language
31+ ) ;
3032 useEffect ( ( ) => {
3133 dispatch ( setLanguage ( language , { persistPreference : false } ) ) ;
3234 } , [ language ] ) ;
3335
34- // TODO: do we actually need this? - Linda
35- const [ isMounted , setIsMounted ] = useState ( false ) ;
36- useEffect ( ( ) => setIsMounted ( true ) , [ ] ) ;
37-
3836 const previousLocationRef = useRef ( location ) ;
3937 useEffect ( ( ) => {
4038 const prevLocation = previousLocationRef . current ;
@@ -52,18 +50,8 @@ const App = ({ children }) => {
5250 return (
5351 < div className = "app" >
5452 < CookieConsent hide = { hide } />
55- { isMounted && showReduxDevTools ( ) && < DevTools /> }
53+ { showReduxDevTools ( ) && < DevTools /> }
5654 { children }
5755 </ div >
5856 ) ;
5957} ;
60-
61- App . propTypes = {
62- children : PropTypes . element
63- } ;
64-
65- App . defaultProps = {
66- children : null
67- } ;
68-
69- export default App ;
0 commit comments