Content
@
0 reply
0 recast
0 reaction
androidsixteen 🌲
@androidsixteen.eth
I miss explicit component lifecycle methods in React like `componentDidMount` Felt far easier to reason about than 15 `useEffect` functions littered in the component where you have to inspect the dependency array to know what's going on Am I just being redacted / is there a better approach here?
9 replies
2 recasts
19 reactions
Royal
@royalaid.eth
It's just understanding the shift to a slightly more implicit behavior. I think hooks, and the implicit return cleanup function, co-locate logic better.
1 reply
0 recast
2 reactions
Royal
@royalaid.eth
Fwiw, you can mimic the behavior by setting up a useEffect with [] in the deps array and that is considered the idiomatic way to handle on Mount in my experience
1 reply
0 recast
0 reaction
androidsixteen 🌲
@androidsixteen.eth
Yeah, I'm aware -- and using the cleanup callback within that method to handle unmount But it just feels too implicit / not easy to manage when you have a lot of logic predicated on state changes
2 replies
0 recast
0 reaction
Royal
@royalaid.eth
Feels like those state vars should just be in the dep array but I'm sure I'm over generalizing and would need to peep the actual code 😅
1 reply
0 recast
0 reaction
androidsixteen 🌲
@androidsixteen.eth
Nah, I think I just dislike this pattern and am venting 😆 It's perfectly functional Also I use the exhaustive-deps lint rule which keeps gaslighting me
0 reply
0 recast
1 reaction