提前谢谢!! 我有麻烦了,我不知道我的地图出什么问题了。我是新来的学生(JS,React,Redux)。它应该显示一个列表(或至少一个名字,任何东西),但是什么也没发生。
import React, {Component} from "react";
import { connect } from "react-redux";
import { push } from "connected-react-router";
import { getTrips } from "../../actions/allActions";
import List from "@material-ui/core/List";
class ListTrips extends Component {
componentDidMount() {
this.props.getTripsAction();
}
render() {
return (
<List>
{
this.props.trips.map((trip) => {
return(<li>{trip.name}</li>)
})
}
</List>
);
}
}
const mapStateToProps = state => ({
trips: state.trips.trips
});
const mapDispatchToProps = dispatch => ({
getTripsAction: () => dispatch(getTrips()),
});
export default connect(
mapStateToProps,
mapDispatchToProps
)(ListTrips)