Skip to content

Commit 6f1756e

Browse files
committed
add runtime deprecation notice for jotai-fmaily
1 parent 27e1060 commit 6f1756e

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/vanilla/utils/atomFamily.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ export interface AtomFamily<Param, AtomType> {
3939
unstable_listen(callback: Callback<Param, AtomType>): Cleanup
4040
}
4141

42+
let didWarnDeprecation = false
43+
4244
/**
4345
* @deprecated atomFamily is deprecated and will be removed in v3.
4446
* Please use the `jotai-family` package instead: https://github.com/jotaijs/jotai-family
@@ -63,6 +65,13 @@ export function atomFamily<Param, AtomType extends Atom<unknown>>(
6365
initializeAtom: (param: Param) => AtomType,
6466
areEqual?: (a: Param, b: Param) => boolean,
6567
) {
68+
if (import.meta.env?.MODE !== 'production' && !didWarnDeprecation) {
69+
console.warn(
70+
'[DEPRECATED] atomFamily is deprecated and will be removed in v3. ' +
71+
'Please use the `jotai-family` package instead: https://github.com/jotaijs/jotai-family',
72+
)
73+
didWarnDeprecation = true
74+
}
6675
let shouldRemove: ShouldRemove<Param> | null = null
6776
const atoms: Map<Param, [AtomType, CreatedAt]> = new Map()
6877
const listeners = new Set<Callback<Param, AtomType>>()

0 commit comments

Comments
 (0)