Skip to content

Commit 0d938c7

Browse files
authored
Update readme 3 (#78)
* update readme * update readme * update version to v0.8.2
1 parent e9c1225 commit 0d938c7

File tree

2 files changed

+14
-18
lines changed

2 files changed

+14
-18
lines changed

README.md

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@
44

55
## ScopeProvider
66

7-
`<ScopeProvider>` lets you reuse the *same* atoms in different parts of the React tree **without sharing state** while still be able to read other atoms from the parent store.
7+
`<ScopeProvider>` lets you reuse the *same* atoms in different parts of the React tree **without sharing state** while still being able to read other atoms from the parent store.
88

99
---
1010

1111
### At‑a‑glance
1212

13-
* Scopes are opt‑in. Only atoms listed in `atoms` or `atomFamilies`.
13+
* Scopes are opt‑in. Only atoms listed in `atoms` or `atomFamilies` are explicitly scoped.
1414
* **Unscoped derived** atoms can read both unscoped and scoped atoms.
15-
* **Scoped derived** atoms implicitly scope their atom dependencies. When you scope a derived atom, every atom it touches (recursive) is scoped automatically, but only when read by the derived atom. Outside the derived atom, it continues to be unscoped.
15+
* **Scoped derived** atoms implicitly scope their atom dependencies. When you scope a derived atom, every atom it touches (recursively) is scoped automatically, but only when read by the derived atom. Outside the derived atom, it continues to be unscoped.
1616
* **Nested lookup.** If a scope can’t find the atom in the current scope, it inherits from the nearest parent scope, up to the nearest store.
1717
* Scoping works for both reading from atoms *and* writing to atoms.
1818

@@ -54,7 +54,7 @@ export default function App() {
5454
}
5555
```
5656

57-
The second counter owns a private `doubledAtom` *and* a private `countAtom` because`doubledAtom` is scoped.
57+
The second counter owns a private `doubledAtom` *and* a private `countAtom` because `doubledAtom` is scoped.
5858

5959
---
6060

@@ -70,15 +70,15 @@ The second counter owns a private `doubledAtom` *and* a private `countAtom` b
7070
```
7171

7272
* Outer scope (S1) isolates `countAtom`.
73-
* Inner scope (S2) isolates `nameAtom` and looks up the tree and finds `countAtom` in S1
73+
* Inner scope (S2) isolates `nameAtom`, then looks up the tree and finds `countAtom` in S1.
7474

7575
---
7676

7777
**3 · Providing default values**
7878

7979
```tsx
8080
<ScopeProvider atoms={[[countAtom, 42]]}>
81-
<Counter /> {/* starts at 42 inside this scope, yay! */}
81+
<Counter /> {/* starts at 42 inside this scope */}
8282
</ScopeProvider>
8383
```
8484

@@ -113,18 +113,18 @@ S1[a]: a1, b0, c0(a1 + b0), d0(a1 + c0(a1 + b0))
113113
S2[c, d]: a1, b0, c2(a2 + b2), d2(a2 + c2(a2 + b2))
114114
```
115115
Above:
116-
- Scope **S1** is the first scope under the store provider (**S0**). **S1** scopes **a**, so **a1** refers to the scoped **a** in **S1**.
117-
- **c** is a derived atom. **c** reads **a** and **b**. In **S1**, **c** is not scoped so it reads **a1** and **b0** from **S1**.
118-
- **c** is scoped in **S2**, so it reads **a** from **S2** and **b** from **S2**. This is because atom dependencies of scoped atoms are _implicitly scoped_.
119-
- Outside **c** and **d** in **S2**, **a** and **b** still inherit from **S1**.
120-
- **c** and **d** are both scoped in **S2**, so they both reads **a2** and **b2**. **c** and **d** share the same atom dependencies. **a2** in **c2** and **a2** in **d2** are the same atom.
116+
- Scope **S1** is the first scope under the store provider (**S0**). **S1** scopes **a**, so **a1** refers to the scoped **a** in **S1**.
117+
- **c** is a derived atom. **c** reads **a** and **b**. In **S1**, **c** is not scoped so it reads **a1** and **b0** from **S1**.
118+
- **c** is scoped in **S2**, so it reads **a** from **S2** and **b** from **S2**. This is because atom dependencies of scoped atoms are _implicitly scoped_.
119+
- Outside **c** and **d** in **S2**, **a** and **b** still inherit from **S1**.
120+
- **c** and **d** are both scoped in **S2**, so they both read **a2**. Implicit dependencies are shared across scoped atoms in the same scope so **a2** in **c2** and **a2** in **d2** are the same atom.
121121

122122
### API
123123

124124
```ts
125125
interface ScopeProviderProps {
126-
atoms: (Atom<any> | [WritableAtom<any, any[], any>, any])[]
127-
atomFamilies: AtomFamily<any, any>[]
126+
atoms?: (Atom<any> | [WritableAtom<any, any[], any>, any])[]
127+
atomFamilies?: AtomFamily<any, any>[]
128128
children: React.ReactNode
129129
debugName?: string
130130
}
@@ -156,7 +156,3 @@ function Library() {
156156
)
157157
}
158158
```
159-
160-
---
161-
162-
MIT © 2025 jotai‑scope team

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "jotai-scope",
3-
"version": "0.8.1",
3+
"version": "0.8.2",
44
"description": "👻🔭",
55
"type": "module",
66
"author": "Daishi Kato",

0 commit comments

Comments
 (0)