1
- import React from 'react' ;
1
+ import React , { useCallback , useContext } from 'react' ;
2
2
import PropTypes from 'prop-types' ;
3
3
4
4
import {
@@ -48,6 +48,7 @@ import {
48
48
} from '../../../icons/1x1' ;
49
49
import { Ph as PhIcon , Us as UsIcon } from '../../../icons/flags/4x3' ;
50
50
import { Skeleton } from '../../../ui' ;
51
+ import { AppContext } from '../../../AppContext' ;
51
52
52
53
const UserAvatar = props => {
53
54
const { user } = props ;
@@ -151,15 +152,15 @@ const LocaleMenu = props => {
151
152
} ;
152
153
153
154
const AccountMenu = props => {
155
+ const { user, handleLock, handleSignOut } = useContext ( AppContext ) ;
156
+
154
157
const {
155
158
history,
156
159
classes,
157
- pageProps,
158
160
159
161
accountMenuOpen,
160
162
onAccountMenuToggle,
161
163
} = props ;
162
- const { user, handleLock, handleSignOut } = pageProps ;
163
164
164
165
const navigate = path => history . push ( path ) ;
165
166
@@ -191,12 +192,10 @@ const AccountMenu = props => {
191
192
</ ListItemAvatar >
192
193
193
194
< ListItemText >
194
- < Typography >
195
- { pageProps . user . name }
196
- </ Typography >
195
+ < Typography > { user . name } </ Typography >
197
196
198
197
< Typography color = "textSecondary" >
199
- { pageProps . user . email }
198
+ { user . email }
200
199
</ Typography >
201
200
</ ListItemText >
202
201
</ MenuItem >
@@ -260,7 +259,6 @@ const AccountMenu = props => {
260
259
function Header ( props ) {
261
260
const {
262
261
classes,
263
- pageProps,
264
262
pageTitle,
265
263
loading,
266
264
@@ -277,10 +275,11 @@ function Header(props) {
277
275
278
276
const {
279
277
user,
278
+
280
279
monitoringEnabled,
281
280
nightMode,
282
281
handleNightModeToggled,
283
- } = pageProps ;
282
+ } = useContext ( AppContext ) ;
284
283
285
284
const skeletonProps = {
286
285
color : colors . grey [ 400 ] ,
@@ -711,7 +710,6 @@ function Header(props) {
711
710
712
711
Header . propTypes = {
713
712
classes : PropTypes . object . isRequired ,
714
- pageProps : PropTypes . object . isRequired ,
715
713
pageTitle : PropTypes . string . isRequired ,
716
714
loading : PropTypes . bool ,
717
715
0 commit comments