Skip to content

Instantly share code, notes, and snippets.

@lsmoura
Created June 24, 2019 19:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lsmoura/f3cf2c7d29ef006a162bf4e54259ec95 to your computer and use it in GitHub Desktop.
Save lsmoura/f3cf2c7d29ef006a162bf4e54259ec95 to your computer and use it in GitHub Desktop.
Material UI demo with class components
import React from 'react';
import { makeStyles } from '@material-ui/core/styles';
import List from '@material-ui/core/List';
import ListItem from '@material-ui/core/ListItem';
import ListItemIcon from '@material-ui/core/ListItemIcon';
import ListItemText from '@material-ui/core/ListItemText';
import Divider from '@material-ui/core/Divider';
import InboxIcon from '@material-ui/icons/Inbox';
import DraftsIcon from '@material-ui/icons/Drafts';
const useStyles = makeStyles(theme => ({
root: {
width: '100%',
maxWidth: 360,
backgroundColor: theme.palette.background.paper,
},
}));
function ListItemLink(props) {
return <ListItem button component="a" {...props} />;
}
class SimpleList extends React.Component {
constructor(props) {
super(props);
this.classes = useStyles();
}
render() {
const classes = this.classes;
return (
<div className={classes.root}>
<List component="nav" aria-label="Main mailbox folders">
<ListItem button>
<ListItemIcon>
<InboxIcon />
</ListItemIcon>
<ListItemText primary="Inbox" />
</ListItem>
<ListItem button>
<ListItemIcon>
<DraftsIcon />
</ListItemIcon>
<ListItemText primary="Drafts" />
</ListItem>
</List>
<Divider />
<List component="nav" aria-label="Secondary mailbox folders">
<ListItem button>
<ListItemText primary="Trash" />
</ListItem>
<ListItemLink href="#simple-list">
<ListItemText primary="Spam" />
</ListItemLink>
</List>
</div>
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment