我的组件在Selected
中具有属性<ListItem Button/>
好的,但是我更改了此菜单,并且希望在选择菜单时选择另一个元素。如何将状态更改转移到组件? (我正在学习react.js)
import React, { Fragment, Component } from 'react';
import ListItemIcon from '@material-ui/core/ListItemIcon';
import ListItemText from '@material-ui/core/ListItemText';
import ListItem from '@material-ui/core/ListItem';
import List from '@material-ui/core/List';
import Divider from '@material-ui/core/Divider';
import { Home, Payment, Settings } from '@material-ui/icons/';
export default class Navigation extends Component {
state = {};
render() {
return (
<Fragment>
<Divider />
<List component="nav">
<ListItem button selected>
<ListItemIcon>
<Home />
</ListItemIcon>
<ListItemText primary="Strona główna" />
</ListItem>
<ListItem button>
<ListItemIcon>
<Payment />
</ListItemIcon>
<ListItemText primary="Moje płatności" />
</ListItem>
</List>
<Divider />
<List component="nav">
<ListItem button>
<ListItemIcon>
<Settings />
</ListItemIcon>
<ListItemText primary="Ustawienia" />
</ListItem>
</List>
</Fragment>
);
}
}