From 7655517294e5060d5317c2bfd4d96dd03f273661 Mon Sep 17 00:00:00 2001 From: Eugene Zaretskiy Date: Thu, 23 Dec 2021 21:33:52 -0500 Subject: [PATCH 1/2] docs: Fix broken util links (#907) * Fix broken links * Fix broken doc links Co-authored-by: Eugene Zaretskiy --- docs/api/utils.mdx | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/docs/api/utils.mdx b/docs/api/utils.mdx index bfc032258a..3677ba5c49 100644 --- a/docs/api/utils.mdx +++ b/docs/api/utils.mdx @@ -8,79 +8,79 @@ This is an overview over atom creators/hooks utilities that can found under `jot ## Overview -1. [atomWithStorage](../utils/atom-with-storage) +1. [atomWithStorage](../utils/atom-with-storage.mdx) The `atomWithStorage` function creates an atom with a value persisted in `localStorage` or `sessionStorage` for React or `AsyncStorage` for React Native. -2. [atomWithObservable](../utils/atom-with-observable) +2. [atomWithObservable](../utils/atom-with-observable.mdx) The `atomWithObservable` function creates an atom from a rxjs (or similar) `subject` or `observable`. Its value will be last value emitted from the stream. -3. [useUpdateAtom](../utils/use-update-atom) +3. [useUpdateAtom](../utils/use-update-atom.mdx) Use `useUpdateAtom` and write-only atoms to avoid re-render. -4. [useAtomValue](../utils/use-atom-value) +4. [useAtomValue](../utils/use-atom-value.mdx) Returns the value of the given atom. -5. [atomWithReset](../utils/atom-with-reset) +5. [atomWithReset](../utils/atom-with-reset.mdx) Creates an atom that could be reset to its `initialValue` with `useResetAtom` hook. -6. [useResetAtom](../utils/use-reset-atom) +6. [useResetAtom](../utils/use-reset-atom.mdx) Resets a Resettable atom to its initial value. -7. [RESET](../utils/reset) +7. [RESET](../utils/reset.mdx) Special value that is accepted by Resettable atoms created with `atomWithReset`, `atomWithDefault` or writable atom created with atom if it accepts `RESET` symbol. -8. [useReducerAtom](../utils/use-reducer-atom) +8. [useReducerAtom](../utils/use-reducer-atom.mdx) Use this hook to update an atom value with a reducer function. -9. [atomWithReducer](../utils/atom-with-reducer) +9. [atomWithReducer](../utils/atom-with-reducer.mdx) This is a function to create an atom with an embeded reducer function to update the value. -10. [atomWithDefault](../utils/atom-with-default) +10. [atomWithDefault](../utils/atom-with-default.mdx) This is a function to create an overwritable primitive atom. Its default value can be specified with a read function instead of a static initial value. -11. [atomWithHash](../utils/atom-with-hash) +11. [atomWithHash](../utils/atom-with-hash.mdx) This creates a new atom that is connected with URL hash. -12. [atomFamily](../utils/atom-family) +12. [atomFamily](../utils/atom-family.mdx) This will create a function that takes param and returns an atom. -13. [selectAtom](../utils/select-atom) +13. [selectAtom](../utils/select-atom.mdx) This function creates a derived atom whose value is a function of the original atom's value, determined by `selector`. -14. [useAtomCallback](../utils/use-atom-callback) +14. [useAtomCallback](../utils/use-atom-callback.mdx) This hook allows to interact with atoms imperatively. -15. [freezeAtom](../utils/freeze-atom) +15. [freezeAtom](../utils/freeze-atom.mdx) The `freezeAtom` takes an existing atom and returns a new derived atom. The value with the new derived atom will be frozen (= not mutable). -16. [freezeAtomCreator](../utils/freeze-atom-creator) +16. [freezeAtomCreator](../utils/freeze-atom-creator.mdx) Instead of create a frozen atom from an existing atom, `freezeAtomCreator` takes an atom creator function and returns a new function. -17. [splitAtom](../utils/split-atom) +17. [splitAtom](../utils/split-atom.mdx) The `splitAtom` utility is useful for when you want to get an atom for each element in a list. -18. [waitForAll](../utils/wait-for-all) +18. [waitForAll](../utils/wait-for-all.mdx) The `waitForAll` utility is a concurrency helper, which allows us to evaluate multiple async atoms. -19. [useHydrateAtoms](../utils/use-hydrate-atoms) +19. [useHydrateAtoms](../utils/use-hydrate-atoms.mdx) The primary use case for `useHydrateAtoms` are SSR apps like Next.js, where an initial value is e.g. fetched on the server, which can be passed to a component by props. From 5e6da031031aaf7f8ad7b084dcf15bdbb2f8b84d Mon Sep 17 00:00:00 2001 From: Daishi Kato Date: Tue, 28 Dec 2021 21:58:23 +0900 Subject: [PATCH 2/2] breaking(types): remove deprecated types (#884) --- src/core/atom.ts | 4 ---- src/utils/atomFamily.ts | 18 +----------------- 2 files changed, 1 insertion(+), 21 deletions(-) diff --git a/src/core/atom.ts b/src/core/atom.ts index 957e59b705..78ba21db81 100644 --- a/src/core/atom.ts +++ b/src/core/atom.ts @@ -61,10 +61,6 @@ type OnMount> = < export type Atom = { toString: () => string debugLabel?: string - /** - * @deprecated Instead use `useAtom(atom, scope)` - */ - scope?: Scope read: Read } diff --git a/src/utils/atomFamily.ts b/src/utils/atomFamily.ts index 349d4202de..59c14cfc5c 100644 --- a/src/utils/atomFamily.ts +++ b/src/utils/atomFamily.ts @@ -1,4 +1,4 @@ -import type { Atom, WritableAtom } from 'jotai' +import type { Atom } from 'jotai' type ShouldRemove = (createdAt: number, param: Param) => boolean @@ -13,22 +13,6 @@ export function atomFamily>( areEqual?: (a: Param, b: Param) => boolean ): AtomFamily -/** - * @deprecated type (use atomFamily>) - */ -export function atomFamily( - initializeAtom: (param: Param) => WritableAtom, - areEqual?: (a: Param, b: Param) => boolean -): AtomFamily> - -/** - * @deprecated type (use atomFamily>) - */ -export function atomFamily( - initializeAtom: (param: Param) => Atom, - areEqual?: (a: Param, b: Param) => boolean -): AtomFamily> - export function atomFamily>( initializeAtom: (param: Param) => AtomType, areEqual?: (a: Param, b: Param) => boolean