我不明白,为什么会有这个错误:
Cannot read property 'map' of undefined
。 (第15行)
这是我的文件:index.js 那我该如何解决这个问题呢?请帮忙。我已经为这个问题苦苦挣扎了几天。
import React, { Fragment } from 'react';
import {
Grid, Paper, Typography, List
} from '@material-ui/core/';
import { ListItem, ListItemText } from '@material-ui/core/List';
const styles = {
Paper: { padding: 20, marginTop: 10, marginBottom: 10 }
};
export default ({ exercises }) => (
<Grid container>
<Grid item sm>
<Paper style={styles.Paper}>
{exercises.map(([group, exercises]) => (
<Fragment>
<Typography variant="headline" style={{ textTransform: 'capitalize' }}>
{group}
</Typography>
<List component="ul">
{exercises.map(({ title }) => (
<ListItem button>
<ListItemText primary={title} />
</ListItem>
))}
</List>
</Fragment>
))}
</Paper>
</Grid>
<Grid item sm>
<Typography variant="display1">Hello</Typography>
<Typography variant="subheading" style={{ marginTop: 20 }}>
Please select an exercise from the list on the left.
</Typography>
</Grid>
</Grid>
);