Skip to content

Commit

Permalink
v1.4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
suhaotian committed Apr 22, 2024
1 parent c66df3b commit 5a55aed
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 2 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
19 changes: 18 additions & 1 deletion example/PersistExample.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,31 @@ 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<typeof count>({
key: '@count-store-key',
getState: () => count,
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<typeof count>({
// key: '@count-store-key',
// getState: () => count,
// setState: setCount,
// // setState: (state) => setCount(state),
// });
if (!isReady) return <div>Loading</div>;

return (
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "use-one",
"version": "1.4.0-beta.4",
"version": "1.4.0",
"license": "MIT",
"packageManager": "[email protected]",
"repository": {
Expand Down

0 comments on commit 5a55aed

Please sign in to comment.