What Hooks Mean for Vue

What Hooks Mean for Vue

Hooks address these concerns by allowing us to define a component’s stateful logic using only function calls. When hooks were announced in React, people were excited — you can see some of the benefits illustrated here, with regards to how they reduce code and repetition:

In terms of maintenance, simplicity is key, and Hooks provide a single, functional way of approaching shared logic with the potential for a smaller amount of code. In the first hook:

Then, in the second we use this to create a conditional that fires the animation logic:

Then, in the component itself, we’ll pass one into the other:

Now we can compose logic with Hooks throughout our application!

Source: css-tricks.com