Name your useEffect functions.

The title pretty much sums up the entire post, but I’ll drop my two cents anyway:

  • It makes it clear what the purpose of that effect is. This means your colleagues spend less time figuring that out.
  • It’s going to force you to only deal with one concern per effect rather than bundling way too many things into one.

As someone who’s always reading new code at $DayJob, I have learned and realised over time that these are things that constantly frustrate me. It takes up unnecessary mental space while working through a problem. Of course until now, it didn’t click for me at all that this was something you could (or should) do.

I’m going to be investing a little bit of time every time I see this to update the code. Ultimately to make it easier for me, my colleagues, and whoever gets on to these projects in the future to reason about it.

4

Comment via email.