And the 12 LOC example allows you to change the logic in one place and not two. While more verbose, this does make it harder to introduce bugs by forgetting to update the logic everywhere it is used (copy/pasted)
It doesn't matter anyway. With or without the function, the class example compares unfavorably to the hooks example.
I am not against Hooks, but I do not believe the example portrait the situation properly.