Skip to content

Commit cda93f4

Browse files
committed
Hookstate-4 migration guide added
1 parent ca65475 commit cda93f4

File tree

2 files changed

+36
-9
lines changed

2 files changed

+36
-9
lines changed

docs/index/docs/10-migrating-to-v4.md

Lines changed: 35 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,42 @@ title: Migrating to version 4
44
sidebar_label: Migrating to version 4
55
---
66

7-
We are in the transitionary state developing, releasing and battle testing Hookstate 4 RC (release candidates) versions.
8-
Once we finish stabilizing the 4th major release, we will provide all of the details on the migration.
9-
Before then, you are advised to state with the latest release of the 3rd version.
7+
## How to migrate from v3 to v4?
108

11-
The list of changes:
9+
- Update your app dependencies for `@hookstate/core` to the version `4.0.0-rc21` (**this exact version**). Leave the plugins at the latest version 3.
10+
- Make your app running again. It should be fairly smooth as `4.0.0-rc21` version is the last version of Hookstate-4, which supported Hookstate-3 plugins, and has only a couple rarely used feature removed.
11+
- Move Hookstate-3 plugins to corresponding Hookstate-4 extensions.
12+
- Port your custom plugins to Hookstate-4 extensions interface.
13+
- Update all `@hookstate/*` dependencies to the latest `4.x` version of Hookstate.
14+
15+
## Changes overview
16+
17+
Hookstate-4 is a major release of Hookstate from the version 3 with non-backward compatible API and behavior changes.
18+
19+
### What is new?
20+
21+
- The biggest feature of Hookstate-4 is support for useEffect, useMemo and other React functions which take dependency lists. Hookstate is the first state management library which makes it possible for a mutable data source to work with dependency lists.
22+
- The next big feature is type safe extensions. Previously known as plugins. Extensions are type safe and allow to add custom extension methods and properties to a State object. There are also new standard extensions which enable serialization, cloning and other features which are typically used in advanced large applications.
23+
- Hookstate-4 can hold values of any type, including instances of custom classes and standard classes, like Date.
24+
- Hookstate-4 supports React 18 and its strict mode.
25+
- Hookstate-4 integrates asynchronous state with React 18 Suspend feature.
26+
- `isHookstate` and `isHookstateValue` allow to check any variable if it is a State of a value of a State.
27+
- `configure` function helps to setup the Hookstate module for development and other specific environments. This enabled some undisclosed commercial application to be moved from Angular to React smoothly, having the state managed by Hookstate and shared / used by both frameworks.
28+
29+
### What has changed?
1230

1331
Version 3 | Version 4 | Description
1432
-|-|-
15-
16-
<!-- `State.[self]` | N/A | `self` property has been removed. It is not necessary to use `[self]` property anymore in order to access state methods. Check out update [nested states](./nested-state) section for details about accessing nested states and state methods.
17-
`StateMethods.keys()` | `StateMethods.key` | `keys` now is a property, not a method.
18-
`StateMethods.map(...)` | N/A | `map` method has been removed as it was confusing and conflicting with `Array.map`. [Asynchronous state](./asynchronous-state) and [Exporting state](./exporting-state) sections have been updated to use the alternative to `map` syntax. -->
33+
State object is new on each rerender | State object is stable | useHookstate returns the same instance of State object if the subscribed State has not changed. It allows the State instance be used in dependency lists of useEffect and other hooks correctly as any other regular variables.
34+
createState, createHookstate | hookstate | Global state creation function has changed its name and signature
35+
useState | useHookstate | State subscription function has changed its name and signature. This function name also works with React development tools
36+
State.destroy | destroy | Destruction of a global state is done by a Hookstate module destroy function, but not a method.
37+
Downgraded | `State.get({ noproxy: true })` | Downgraded plugin is gone. There is now the explicit interface to get the original object without it being wrapped in a proxy.
38+
Untracked | `State.get({ silent: true }) | Untracked plugin has been replaced by type safe more explicit interface.
39+
State.attach | hookstate, useHookstate, extend | Attach method is replaced by the extension argument of `hookstate` and `useHookstate` functions + `extend` function allows to combine multiple extensions.
40+
State.value/get writable | State.value/get is immutable | Hookstate-4 prevents the state value being modified directly by the Typescript "deep readonly" typing.
41+
Misleading State source switchover possible | State switchover is an error | Hookstate-4 throws an error when useHookstate receives a value, which requires to hook into a different data source on rerender.
42+
State.batch | React native | State updates batching is now supported by React natively
43+
postpone | State.promise | It is possible to provide `then` callback for the asynchronous state.
44+
IE11 support | No IE11 support | Dropped legacy feature.
45+

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@hookstate/workspace",
3-
"version": "3.0.13",
3+
"version": "4.0.0-rc21",
44
"description": "The workspace for @hookstate.",
55
"license": "MIT",
66
"author": {

0 commit comments

Comments
 (0)