From 5a55aed59fe4f287729e5e04e4d30b2d5a7caa23 Mon Sep 17 00:00:00 2001 From: suhaotian Date: Mon, 22 Apr 2024 20:02:06 +1000 Subject: [PATCH] v1.4.0 --- CHANGELOG.md | 10 ++++++++++ example/PersistExample.tsx | 19 ++++++++++++++++++- package.json | 2 +- 3 files changed, 29 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7977470..d1e855b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,15 @@ # CHANGELOG +### 1.4.0 + +🥳 Beta finally end, publish v1.4.0 + +New features compare to v1.1.1: + +- Feat: Add `persistStore` to persist your store +- Feat: Add `usePersist` to persist react hook's state +- Chore(README): README reorganize and code reorganize + ### 1.4.0-beta.4 - Fix: `isReady` always false after clean diff --git a/example/PersistExample.tsx b/example/PersistExample.tsx index 70d1979..7d13979 100644 --- a/example/PersistExample.tsx +++ b/example/PersistExample.tsx @@ -2,7 +2,7 @@ import { useState } from "react"; import { usePersist } from "use-one"; import React = require("react"); -export function PersistCounter() { +function useCount() { const [count, setCount] = useState(0); const [isReady, cleanCache] = usePersist({ key: '@count-store-key', @@ -10,6 +10,23 @@ export function PersistCounter() { setState: setCount, // setState: (state) => setCount(state), }); + return { + isReady, + cleanCache, + count, + setCount, + } +} + +export function PersistCounter() { + const { count, setCount, isReady, cleanCache } = useCount(); + // const [count, setCount] = useState(0); + // const [isReady, cleanCache] = usePersist({ + // key: '@count-store-key', + // getState: () => count, + // setState: setCount, + // // setState: (state) => setCount(state), + // }); if (!isReady) return
Loading
; return ( diff --git a/package.json b/package.json index 0c70c1c..8041188 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "use-one", - "version": "1.4.0-beta.4", + "version": "1.4.0", "license": "MIT", "packageManager": "pnpm@7.28.0", "repository": {