The original example has 10 LOC, yours has 12.
> The class example is misleading in terms of the line of code.
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.