Deleting a record using Mongoose with Redux Deleting a record using Mongoose with Redux mongoose mongoose

Deleting a record using Mongoose with Redux


You haven't connected your action to your component:

export default connect(mapStateToProps, { fetchSurveys, deleteSurvey })(SurveyList);

Edit: Your second error is coming from the fact that map only works over arrays so you need to confirm that surveys is an array which you can do using: console.log(this.props.surveys)


You need to use React-Redux's connect higher order function to map the action to your component.

Note: this is not how you should write your code and is just for demonstration

import React from 'react';import { connect } from 'react-redux';import { deleteSurvey } from "../../actions";const SurveyList = ({ survey, handleDeleteSurvey }) => {  return <div>            <button              onClick={() => handleDeleteSurvey(survey._id)}              className="btn-floating btn-large red" >              <i className="material-icons">clear</i>            </button>         </div>}const mapStateToProps = ({ surveys }) => {  return {     surveys   } }const mapDispatchToProps = dispatch => {  return {    //note that this code assumes deleteSurvery is a thunk    handleDeleteSurvey: id => dispatch(deleteSurvey(id))  }}export default connect(mapStateToProps, mapDispatchToProps)(SurveyList);