Migrating to version 2

Hookstate library is moving towards releave version 2. The releases 1.8.x support 99% of the version 2 functionality. So, you can use version 1 and 2 API together with the 1.8.x release.

When version 2 is released finally, it will have all version 1 interfaces, types and function removed.

Version 2 API is simpler. Hookstate library is smaller and faster.

Here is the changes:

Version 1Version 2Description
useStateLink default exportNo default exportThere is no default export in the 2nd version.
useStateLinkuseStateNew function with nearly the same functionality. The returned result of a new type State which has got different way of dealing with nested states.
createStateLinkcreateStateNew function with nearly the same functionality. The returned result of a new type State which has got different way of dealing with nested states.
StateLinkStateNew type of a state instance to access and manage a state. See below the details of changes.
nested property of StateLinkdeletedUse properties of State directly to access nested states.
access property of StateLinkdeletedUse State directly to access instead. See global state docs for more details.
promised, error, batch members of StateLinkdeletedReplaced by map method. See how to deal with asynchronous states.
denull method of StateLinkmoved to ornull property of State / StateMethodsSee how to deal with nullable states.
with method of StateLinkmoved to attach of State or StateMethodsSee how to attach plugins to states.
other properties/methods of StateLinkmoved to StateMethods (and State for primitive states)For a State of a primitive value, get, set, merge, value, keys should be just work without changes. For a State of an object / array, StateMethods are accessible with [self] symbol. In other words, stateLink.set(...) becomes state[self].set(...). See how to deal with nested states.
StateFragmentStateFragmentstate property accepts an instance of type State but not StateLink as before.
StateMemodeletedStateMemo is deleted as it was complex feature with almost no benefit. The same functionality can be more or less achieved with React.memo instead.
transform argument of createStateLink and useStateLinkdeletedSee here how to wrap and export states by a custom interface in the new version.
nonenoneRenamed.