So this is my code in my profile actions
import axios from 'axios';
import { GET_PROFILE, PROFILE_ERROR } from './types';
// Get current users profile
export const getCurrentProfile = () => async (dispatch) => {
try {
const res = await axios.get('/api/profile/me');
dispatch({
type: GET_PROFILE,
payload: res.data,
});
dispatch(getCurrentProfile());
} catch (err) {
dispatch({
type: PROFILE_ERROR,
payload: {
msg: err.response.statusText,
status: err.response.status,
},
});
}
};
and this is my dashboard
import React, { useEffect } from 'react';
import PropTypes from 'prop-types';
import { connect } from 'react-redux';
import { getCurrentProfile } from '../../actions/profile';
const Dashboard = ({ getCurrentProfile, auth, profile }) => {
useEffect(() => {
getCurrentProfile();
}, []);
return <div>Dashboard</div>;
};
Dashboard.propTypes = {
getCurrentProfile: PropTypes.func.isRequired,
auth: PropTypes.object.isRequired,
profile: PropTypes.object.isRequired,
};
const mapStateToProps = (state) => ({
auth: state.auth,
profile: state.profile,
});
export default connect(mapStateToProps, { getCurrentProfile })(Dashboard);
and I get this errror "React Hook useEffect has a missing dependency: 'getCurrentProfile'. Either include it or remove the dependency array. If 'getCurrentProfile' changes too often, find the parent component that defines it and wrap that definition in useCallback"