New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

use-local-storage-state

Package Overview
Dependencies
Maintainers
1
Versions
83
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

use-local-storage-state - npm Package Compare versions

Comparing version 18.1.1 to 18.1.2

es/vitest.config.js

2

es/src/useLocalStorageState.js

@@ -6,3 +6,3 @@ import { useRef, useMemo, useEffect, useCallback, useSyncExternalStore } from 'react';

// istanbul ignore next
if (typeof useSyncExternalStore === 'undefined') {
if (useSyncExternalStore === undefined) {
throw new TypeError(`You are using React 17 or below. Install with "npm install use-local-storage-state@17".`);

@@ -9,0 +9,0 @@ }

{
"name": "use-local-storage-state",
"version": "18.1.1",
"version": "18.1.2",
"description": "React hook that persist data in localStorage",

@@ -5,0 +5,0 @@ "license": "MIT",

@@ -8,3 +8,3 @@ # `use-local-storage-state`

[![Test Coverage](https://img.shields.io/codeclimate/coverage/astoilkov/use-local-storage-state)](https://codeclimate.com/github/astoilkov/use-local-storage-state/test_coverage)
[![Build Status](https://img.shields.io/github/workflow/status/astoilkov/use-local-storage-state/CI)](https://github.com/astoilkov/use-local-storage-state/actions/workflows/main.yml)
[![Build Status](https://img.shields.io/github/actions/workflow/status/astoilkov/use-local-storage-state/main.yml?branch=main)](https://github.com/astoilkov/use-local-storage-state/actions/workflows/main.yml)

@@ -129,2 +129,19 @@ ## Install

<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

@@ -131,0 +148,0 @@

@@ -9,3 +9,3 @@ "use strict";

// istanbul ignore next
if (typeof react_1.useSyncExternalStore === 'undefined') {
if (react_1.useSyncExternalStore === undefined) {
throw new TypeError(`You are using React 17 or below. Install with "npm install use-local-storage-state@17".`);

@@ -12,0 +12,0 @@ }

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc