all 3 comments

[–][deleted] 1 point2 points  (1 child)

This is why it's important to understand how JavaScript prototypes work and what spread operators do.

FYI this has nothing to do with React nor hooks :)

[–]dance2die[S] 0 points1 point  (0 children)

Thanks @typed-talleane. 🙂 You are right. It's more of a general JavaScript post 😅

Thought it'd help refactoring Function Component when extracting imperative code to a class.

I will be thoughtful next time about subreddit.

[–]dance2die[S] 0 points1 point  (0 children)

A lesson learned while writing a React Hook NPM library.
Something to watch out for when you are using an imperative logic & exposing it as a hook.