Created
April 24, 2019 16:39
-
-
Save akhil-gautam/fbe1a74a69bb6f8d97622380301e4171 to your computer and use it in GitHub Desktop.
Authorize my ServerMonitor component so that only Admins can see it
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import * as React from 'react'; | |
import { withAuthorization } from './withAuthorization'; | |
// you can specify interface for props and state, I left it as 'any' | |
class ServerMonitor extends React.Component<any, any> { | |
render(){ | |
return( | |
<> | |
<div> Some monitoring stuff here.... </div> | |
<div> Some more monitoring here.... </div> | |
</> | |
// <></> is an alias for <React.Fragment></React.Fragment> | |
); | |
} | |
} | |
// we are passing our ServerMonitor to our HOC for authorization | |
export default withAuthorization(ServerMonitor); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment