state-in-url 2.2.4 → 2.2.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.CN.md +1 -3
- package/README.KO.md +1 -3
- package/README.md +3 -5
- package/dist/useSharedState/useSharedState.mjs +1 -1
- package/package.json +2 -1
package/README.CN.md
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
[English](./README.md) | [한국어](./README.KO.md) | 简体中文
|
|
2
2
|
|
|
3
|
-
<h1 align="center">state-in-url</h1>
|
|
4
|
-
|
|
5
3
|
<div align="center">
|
|
6
|
-
<img src="/assets/
|
|
4
|
+
<img src="/assets/Logo_big.png?raw=true" alt="state-in-url logo"/>
|
|
7
5
|
|
|
8
6
|
<div>轻松在不相关的React组件之间共享状态,具有IDE自动完成和TS验证功能。无需任何麻烦或样板代码。</div>
|
|
9
7
|
</div>
|
package/README.KO.md
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
[English] | 한국어 | [简体中文](./README.CN.md)
|
|
2
2
|
|
|
3
|
-
<h1 align="center">state-in-url</h1>
|
|
4
|
-
|
|
5
3
|
|
|
6
4
|
<div align="center">
|
|
7
|
-
<img src="/assets/
|
|
5
|
+
<img src="/assets/Logo_big.png?raw=true" alt="state-in-url logo"/>
|
|
8
6
|
|
|
9
7
|
<div>IDE 자동 완성 및 TS 검증과 함께 관련 없는 React 컴포넌트 간에 상태를 쉽게 공유할 수 있습니다. 번거로움이나 보일러플레이트 없이 사용 가능합니다.</div>
|
|
10
8
|
</div>
|
package/README.md
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
English | [한국어](./README.KO.md) | [简体中文](./README.CN.md)
|
|
2
2
|
|
|
3
|
-
<h1 align="center">state-in-url</h1>
|
|
4
|
-
|
|
5
3
|
<div align="center">
|
|
6
|
-
<img src="/assets/
|
|
4
|
+
<img src="/assets/Logo_big.png?raw=true" alt="state-in-url logo"/>
|
|
7
5
|
|
|
8
6
|
<div>Easily share state between unrelated React components, with IDE autocomplete and TS validation. Without any hasssle or boilerplate. </div>
|
|
9
7
|
</div>
|
|
@@ -30,7 +28,7 @@ English | [한국어](./README.KO.md) | [简体中文](./README.CN.md)
|
|
|
30
28
|
|
|
31
29
|
<hr />
|
|
32
30
|
|
|
33
|
-
Add a ⭐️ and <a href="https://github.com/asmyshlyaev177" target="_blank">
|
|
31
|
+
Add a ⭐️ and <a href="https://github.com/asmyshlyaev177" target="_blank">follow me</a> to support the project!
|
|
34
32
|
|
|
35
33
|
<hr />
|
|
36
34
|
|
|
@@ -38,7 +36,7 @@ Add a ⭐️ and <a href="https://github.com/asmyshlyaev177" target="_blank">fol
|
|
|
38
36
|
|
|
39
37
|
## Why use state-in-url?
|
|
40
38
|
|
|
41
|
-
`state-in-url` Simple state management with optional URL sync. Share complex states between unrelated React components, TS-friendly, NextJS compatible.
|
|
39
|
+
`state-in-url` Simple state management with optional URL sync. Share complex states between unrelated React components, TS-friendly, NextJS compatible. Most of users don't care about URL, so, can use it to store your app state.
|
|
42
40
|
|
|
43
41
|
# Use cases
|
|
44
42
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import t from"react";import{stateMap as r,subscribers as e}from"../subscribers.mjs";import{useInsertionEffect as n}from"../useInsertionEffect.mjs";import{isSSR as
|
|
1
|
+
import t from"react";import{stateMap as r,subscribers as e}from"../subscribers.mjs";import{useInsertionEffect as n}from"../useInsertionEffect.mjs";import{isSSR as u,isEqual as c}from"../utils.mjs";function s(s,o){const f=t.useRef(s),[a,i]=t.useState((()=>{if(u())return o?o?.():f.current;const t=r.get(f.current);if(t)return t;{const t=o?.()||f.current;return r.set(f.current,t),t}})),m=t.useCallback((t=>{const n=r.get(f.current),u="function"==typeof t?t(n):{...n,...t};c(n,u)||(r.set(f.current,u),e.get(f.current).forEach((t=>{t()})))}),[]);n((()=>{const t=e.add(f.current,(()=>{i(r.get(f.current)||f.current)}));return()=>{t()}}),[]);return{state:a,getState:t.useCallback((()=>r.get(f.current)||f.current),[]),setState:m}}export{s as useSharedState};
|
package/package.json
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "state-in-url",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.5",
|
|
4
4
|
"description": "Library to store state in browser URL, includes hook for NextJS, hook for pure React, and low level helpers.",
|
|
5
5
|
"homepage": "https://github.com/asmyshlyaev177/state-in-url#readme",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"state-management",
|
|
8
8
|
"state management",
|
|
9
9
|
"Next.js",
|
|
10
|
+
"useUrlState",
|
|
10
11
|
"client components communication",
|
|
11
12
|
"signals alternative",
|
|
12
13
|
"query string",
|