diff --git a/README.md b/README.md index df52d49..60351fc 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Effect -[jotai-effect](https://jotai.org/docs/integrations/effect) is a utility package for reactive side effects. +[jotai-effect](https://jotai.org/docs/extensions/effect) is a utility package for reactive side effects. ## install @@ -92,7 +92,7 @@ function MyComponent() { -- **Resistent To Infinite Loops:** +- **Resistant To Infinite Loops:** `atomEffect` does not rerun when it changes a value with `set` that it is watching. @@ -374,7 +374,6 @@ const loggingAtom = withAtomEffect(anAtom, (get, set) => { }) ``` - ## Comparison with useEffect ### Component Side Effects diff --git a/__tests__/withAtomEffect.test.ts b/__tests__/withAtomEffect.test.ts index 73138f5..13aeca8 100644 --- a/__tests__/withAtomEffect.test.ts +++ b/__tests__/withAtomEffect.test.ts @@ -22,6 +22,8 @@ describe('withAtomEffect', () => { store.sub(enhancedAtom, () => {}) store.set(enhancedAtom, 5) expect(store.get(enhancedAtom)).toBe(5) + store.set(enhancedAtom, (prev) => prev + 1) + expect(store.get(enhancedAtom)).toBe(6) }) it('calls effect on initial use and on dependencies change', async () => { diff --git a/package.json b/package.json index 1e815b5..61f6f4e 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "jotai-effect", "description": "👻🔁", - "version": "1.0.2", + "version": "1.0.3", "author": "David Maskasky", "repository": { "type": "git", diff --git a/src/index.ts b/src/index.ts index 119d5fa..7d7c89b 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1 +1,2 @@ export { atomEffect } from './atomEffect' +export { withAtomEffect } from './withAtomEffect'