In a react class component, I have a new function to add to a lifecycle method. I am trying to figure out if it is better to have:
componentDidUpdate() {
const myFunc = () => {
// Do something
}
myFunc();
}
Or:
const myFunc = () => {
// Do something
}
componentDidUpdate() {
this.myFunc();
}
My concern with having myFunc() function created inside of componentDidUpdate, is that the function will get created every time the component re-renders, as opposed to only getting created once. Am I correct in this assumption?