Version 1.4.0 of use-immer-reactn is now available for general use. This version focused on closing the gap between use-immer and use-immer-reactn.
Pass Finished Objects
While most of the time when using the useGlobalImmer
hook you’ll want to pass a callback to take advantage of mutating the draft, sometimes you have a finished object externally and want to replace it.
Now the returned updater function supports passing either a callback or a finished object interchangeably:
Work With Entire State
Sometimes you don’t want the state to be narrowed to a specific property and want to mutate the entire global state. You may now omit the property when calling useGlobalImmer
to receive the entire state object.