I am getting this warning and I was wondering what steps I need to take to remove the warning from my console. The issue being, I am using the fetchProfile() function elsewhere so I can't move it within the useEffect. any suggestions? My code is as follows:
const fetchProfile = async () => {
const token = await localStorage.FBIdToken
await axios
.get(`/user`, {
headers: {
Authorization: `${token}`
}
})
.then(res => {
setUser(res.data)
setFormData({
...formData,
github: res.data.user.github ? res.data.user.github : '',
website: res.data.user.website ? res.data.user.website : '',
linkedIn: res.data.user.linkedIn ? res.data.user.linkedIn : '',
cohort: res.data.user.cohort,
program: res.data.user.program
})
})
.catch(err => console.log('error'))
}
useEffect(() => {
fetchProfile()
}, [])
fetchProfilefunction defined within the component? - Jayce444