Skip to content

Commit 2d5ed4a

Browse files
committed
Add migrateState docs
1 parent f83aeff commit 2d5ed4a

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

packages/dashboard/src/usePersistentState.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,17 @@ export type PersistentStateMigration = {
1616
migrate: (state: unknown) => unknown;
1717
};
1818

19+
/**
20+
* Migrates persisted state to the provided version using the provided migrations.
21+
*
22+
* @param state The current state
23+
* @param from The current version
24+
* @param to The version to migrate to
25+
* @param migrations The list of all migrations (may include those already applied)
26+
* @param type The type of the state. Used for better error messages
27+
* @returns The state at the new version
28+
* @throws Error if trying to migrate backwards or no migration exists for the to version
29+
*/
1930
function migrateState(
2031
state: unknown,
2132
from: number,

0 commit comments

Comments
 (0)