title: React Hook useEffect has a missing dependency: 'props'. Either include it or remove the dependency array. props in useEffect have no data
body: <p>i used axios  to call api methods for data access in react hooks components .i used react redux for state management. i call the fetchall method from useEffect to get all courses. but the response array is empty and show above error.there is problem with state or props like that .or the course reducer does not fetch data .here is code of api.js in action.</p>
  
  <pre><code>import axios from "axios";
  
  const baseUrl = "http://localhost:44306/api/"
  
  
  
  export default {
  
      course(url = baseUrl + 'courses/') {
          return {
              fetchAll: () =&gt; axios.get(url),
              fetchById: id =&gt; axios.get(url + id),
              create: newRecord =&gt; axios.post(url, newRecord),
              update: (id, updateRecord) =&gt; axios.put(url + id, updateRecord),
              delete: id =&gt; axios.delete(url + id)
          }
      }
  }
  </code></pre>
  
  <p>the courses components have 2 grids first Grid has been commented out to focus on problem. the second grid have table which should show courses in table. the backend table has many rows which has been tested with postman and from database. the courses.js is as follows.</p>
  
  <pre><code>import React, { useState, useEffect } from "react";
  import { connect } from "react-redux";
  import * as actions from "../actions/course";
  import { Grid, Paper, TableContainer, Table, TableHead, TableRow, TableCell, TableBody, withStyles, ButtonGroup, Button } from "@material-ui/core";
  import CourseForm from "./CourseForm";
  import EditIcon from "@material-ui/icons/Edit";
  import DeleteIcon from "@material-ui/icons/Delete";
  import { useToasts } from "react-toast-notifications";
  
  
  
  const styles = theme =&gt; ({
      root: {
          "&amp; .MuiTableCell-head": {
              fontSize: "1.25rem"
          }
      },
      paper: {
          margin: theme.spacing(2),
          padding: theme.spacing(2)
      }
  })
  
  
  
  
  
  const Courses = ({ classes, ...props }) =&gt; {
      const [currentId, setCurrentId] =useState(0)
      useEffect(() =&gt; {
          props.fetchAllCourses()    // here is error props is empty
  
      }, [])//componentDidMount
  
      //toast msg.
      const { addToast } = useToasts()
  
      const onDelete = id =&gt; {
          if (window.confirm('Are you sure to delete this record?'))
              props.deleteCourse(id,()=&gt;addToast("Deleted successfully", { appearance: 'info' }))
      }
  
  
  
  
  
      return (
          &lt;Paper className={classes.paper} elevation={3}&gt;
              &lt;Grid container&gt;
                  &lt;Grid item xs={6}&gt;
  
                      {/* &lt;CourseForm {...({ currentId, setCurrentId })} /&gt; */}
                  &lt;/Grid&gt;
                  &lt;Grid item xs={6}&gt;
                      &lt;TableContainer&gt;
                          { &lt;Table&gt;
                              &lt;TableHead className={classes.root}&gt;
                                  &lt;TableRow&gt;
                                      &lt;TableCell&gt;Title&lt;/TableCell&gt;
                                      &lt;TableCell&gt;Details&lt;/TableCell&gt;
                                      &lt;TableCell&gt;Category&lt;/TableCell&gt;
                                      &lt;TableCell&gt;&lt;/TableCell&gt;
                                  &lt;/TableRow&gt;
                              &lt;/TableHead&gt;
                              &lt;TableBody&gt;
                                  {
                                      props.courseList.map((record, index) =&gt; {
                                          return (&lt;TableRow key={index} hover&gt;
                                              &lt;TableCell&gt;{record.Title}&lt;/TableCell&gt;
                                              &lt;TableCell&gt;{record.Details}&lt;/TableCell&gt;
                                              &lt;TableCell&gt;{record.Category}&lt;/TableCell&gt;
                                              &lt;TableCell&gt;
                                                  &lt;ButtonGroup variant="text"&gt;
                                                      &lt;Button&gt;&lt;EditIcon color="primary"
                                                          onClick={() =&gt; { setCurrentId(record.id) }} /&gt;&lt;/Button&gt;
                                                      &lt;Button&gt;&lt;DeleteIcon color="secondary"
                                                          onClick={() =&gt; onDelete(record.id)} /&gt;&lt;/Button&gt;
                                                  &lt;/ButtonGroup&gt;
                                              &lt;/TableCell&gt;
                                          &lt;/TableRow&gt;)
                                      })
                                  }
                              &lt;/TableBody&gt;
                          &lt;/Table&gt; }
                      &lt;/TableContainer&gt;
  
                  &lt;/Grid&gt;
              &lt;/Grid&gt;
          &lt;/Paper&gt;
      );
  }
  
  const mapStateToProps = state =&gt; ({
      courseList: state.course.list
  })
  
  const mapActionToProps = {
      fetchAllCourses: actions.fetchAll,
      deleteCourse: actions.Delete
  }
  
  export default connect(mapStateToProps, mapActionToProps)(withStyles(styles)(Courses));
  </code></pre>
  
  <p>the course.js in actions is as follows:</p>
  
  <pre><code>import api from "./api";
  
  export const ACTION_TYPES = {
      CREATE: 'CREATE',
      UPDATE: 'UPDATE',
      DELETE: 'DELETE',
      FETCH_ALL: 'FETCH_ALL'
  }
  
  const formateData = data =&gt; ({
      ...data,
  
  })
  
  export const fetchAll = () =&gt; dispatch =&gt; {
      api.course().fetchAll()
          .then(response =&gt; {
              console.log(response)
              dispatch({
                  type: ACTION_TYPES.FETCH_ALL,
                  payload: response.data
              })
          })
          .catch(err =&gt; console.log(err))
  }
  
  export const create = (data, onSuccess) =&gt; dispatch =&gt; {
      data = formateData(data)
      api.course().create(data)
          .then(res =&gt; {
              dispatch({
                  type: ACTION_TYPES.CREATE,
                  payload: res.data
              })
              onSuccess()
          })
          .catch(err =&gt; console.log(err))
  }
  
  export const update = (id, data, onSuccess) =&gt; dispatch =&gt; {
      data = formateData(data)
      api.course().update(id, data)
          .then(res =&gt; {
              dispatch({
                  type: ACTION_TYPES.UPDATE,
                  payload: { id, ...data }
              })
              onSuccess()
          })
          .catch(err =&gt; console.log(err))
  }
  
  export const Delete = (id, onSuccess) =&gt; dispatch =&gt; {
      api.course().delete(id)
          .then(res =&gt; {
              dispatch({
                  type: ACTION_TYPES.DELETE,
                  payload: id
              })
              onSuccess()
          })
          .catch(err =&gt; console.log(err))
  }
  </code></pre>
  
  <p>the course.js in reducer is as :</p>
  
  <pre><code>import { ACTION_TYPES } from "../actions/course";
  const initialState = {
      list: []
  }
  
  
  export const course = (state = initialState, action) =&gt; {
  
      switch (action.ACTION_TYPES) {
          case ACTION_TYPES.FETCH_ALL:
              return {
                  ...state,
                  list: [...action.payload]
              }
  
          case ACTION_TYPES.CREATE:
              return {
                  ...state,
                  list: [...state.list, action.payload]
              }
  
          case ACTION_TYPES.UPDATE:
              return {
                  ...state,
                  list: state.list.map(x =&gt; x.id == action.payload.id ? action.payload : x)
              }
  
          case ACTION_TYPES.DELETE:
              return {
                  ...state,
                  list: state.list.filter(x =&gt; x.id != action.payload)
              }
  
          default:
              return state
      }
  }
  </code></pre>
  
  <p>why the useeffect does not access the props. how to access props in useEffect i will be very thankful for kind help.
  the index.js in reducer is as:</p>
  
  <pre><code>import { combineReducers } from "redux";
  import { course } from "./course";
  
  export const reducers = combineReducers({
      course
  })
  </code></pre>
  
  <p>thanks in advance.</p>