.map不显示列表(来自API)

时间:2019-11-05 23:05:14

标签: javascript reactjs redux react-redux

提前谢谢!! 我有麻烦了,我不知道我的地图出什么问题了。我是新来的学生(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)

0 个答案:

没有答案