use-session-storage-state
Advanced tools
Comparing version 18.1.0 to 18.1.1
{ | ||
"name": "use-session-storage-state", | ||
"version": "18.1.0", | ||
"version": "18.1.1", | ||
"description": "React hook that persist data in sessionStorage", | ||
@@ -12,3 +12,3 @@ "license": "MIT", | ||
"email": "hello@astoilkov.com", | ||
"url": "http://astoilkov.com" | ||
"url": "https://astoilkov.com" | ||
}, | ||
@@ -15,0 +15,0 @@ "keywords": [ |
@@ -8,3 +8,3 @@ # `use-session-storage-state` | ||
[![Test Coverage](https://img.shields.io/codeclimate/coverage/astoilkov/use-session-storage-state)](https://codeclimate.com/github/astoilkov/use-session-storage-state/test_coverage) | ||
[![Build Status](https://img.shields.io/github/workflow/status/astoilkov/use-session-storage-state/CI)](https://github.com/astoilkov/use-session-storage-state/actions/workflows/main.yml) | ||
[![Build Status](https://img.shields.io/github/actions/workflow/status/astoilkov/use-session-storage-state/main.yml?branch=main)](https://github.com/astoilkov/use-session-storage-state/actions/workflows/main.yml) | ||
@@ -39,3 +39,2 @@ ## Install | ||
const [todos, setTodos] = useSessionStorageState('todos', { | ||
ssr: true, | ||
defaultValue: ['buy avocado', 'do 50 push-ups'] | ||
@@ -50,3 +49,3 @@ }) | ||
You can experiment with the example [here](https://codesandbox.io/s/todos-example-use-session-storage-state-pewbql?file=/src/App.tsx). | ||
You can experiment with the example [here](https://codesandbox.io/s/todos-example-use-session-storage-state-3s4hhe). | ||
@@ -59,3 +58,2 @@ ```tsx | ||
const [todos, setTodos] = useSessionStorageState('todos', { | ||
ssr: true, | ||
defaultValue: ['buy avocado'] | ||
@@ -86,3 +84,3 @@ }) | ||
<details> | ||
<summary id="is-persistent">Notify the user when <code>sessionStorage</code> isn't saving the data using the <code>`isPersistent`</code> property</summary> | ||
<summary id="is-persistent">Notify the user when <code>sessionStorage</code> isn't saving the data using the <code>isPersistent</code> property</summary> | ||
<p></p> | ||
@@ -135,2 +133,19 @@ | ||
<details> | ||
<summary>Why does my component re-renders twice?</summary> | ||
<p></p> | ||
If you are hydrating your component (for example, if you are using Next.js), your component might re-render twice. This is behavior specific to React and not to this library. It's caused by the `useSyncExternalStore()` hook. There is no workaround. This has been discussed in the issues: https://github.com/astoilkov/use-local-storage-state/issues/56. | ||
If you want to know if you are currently rendering the server value you can use this helper function: | ||
```ts | ||
function useIsServerRender() { | ||
return useSyncExternalStore(() => { | ||
return () => {} | ||
}, () => false, () => true) | ||
} | ||
``` | ||
</details> | ||
## API | ||
@@ -137,0 +152,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
188
0
24908
9
328