Today I Learned…
Watch out when exposing a mutable data structure with React Hooks
When you spread an object instance of a class to expose methods, methods might not be copied over.
Suppose that you have a
which you want to make it immutable by returning a new object using syntax spread.
Not a good idea! Explained later.
trie object instance returned from
useTrie won’t show
has and an empty method is printed.
Let’s see why and how to solve the issue.