I have a React component that is using a map function to show some data. The problem is when I'm passing the callback function to and using the classes property, I'm getting an error that says
Uncaught ReferenceError: classes is not defined
Here's my code. Please note that classes is defined. How do I properly access it on the callback function that I have?
class ProvidersPage extends React.Component {
constructor(props, context) {
super(props, context);
}
providerRow(provider, index) {
return <TableRow className={classes.row} key={index}>
<CustomTableCell component="th" scope="row">
{provider.name}
</CustomTableCell>
<CustomTableCell>{provider.type}</CustomTableCell>
<CustomTableCell>{provider.pointOfContact}</CustomTableCell>
<CustomTableCell>{provider.telephoneNumber}</CustomTableCell>
<CustomTableCell>{provider.licenseNumber}</CustomTableCell>
<CustomTableCell>{provider.licenseSource}</CustomTableCell>
<CustomTableCell>
<IconButton>
<MoreHorizIcon />
</IconButton>
</CustomTableCell>
</TableRow>
}
render() {
const { classes } = this.props;
return (
<div>
<Paper className={classes.root} elevation={4}>
<Table className={classes.table}>
<TableHead>
<TableRow>
<CustomTableCell>Name</CustomTableCell>
<CustomTableCell>Type</CustomTableCell>
<CustomTableCell>Point of Contact</CustomTableCell>
<CustomTableCell>Telephone Number</CustomTableCell>
<CustomTableCell>License Number</CustomTableCell>
<CustomTableCell>License Source</CustomTableCell>
<CustomTableCell>Actions</CustomTableCell>
</TableRow>
</TableHead>
<TableBody>
{this.props.providers.map(this.providerRow)}
</TableBody>
</Table>
</Paper>
</div>
);
}
}