console
class Toggle extends React.Component {
constructor(props) {
super(props);
this.state = {
names: ['小红', '小明', '小李']
};
}
handleClick() {
this.setState(prevState => ({
isToggleOn: !prevState.isToggleOn
}));
}
render() {
let a = this.state.names.map((number) =>{
return <li key={number}>{number}</li>
})
return (
<div>
<ul>
{a}
{ this.state.names.map((number) =>{
return <li key={number}>{number}</li>
})}
</ul>
</div>
);
}
}
ReactDOM.render(
<div>
<Toggle />
</div>,
document.getElementById('root')
);
<div id="root"></div>