Skip to content

Instantly share code, notes, and snippets.

@akhil-gautam
Created April 24, 2019 16:39
Show Gist options
  • Save akhil-gautam/fbe1a74a69bb6f8d97622380301e4171 to your computer and use it in GitHub Desktop.
Save akhil-gautam/fbe1a74a69bb6f8d97622380301e4171 to your computer and use it in GitHub Desktop.
Authorize my ServerMonitor component so that only Admins can see it
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