diff --git a/src/vanilla/atom.ts b/src/vanilla/atom.ts index 8f5d285744f..fd3f151d9ea 100644 --- a/src/vanilla/atom.ts +++ b/src/vanilla/atom.ts @@ -52,7 +52,7 @@ export interface Atom { /** * Fires after atom is referenced by the store for the first time */ - unstable_onInit?: (store: Store) => void + INTERNAL_onInit?: (store: Store) => void } export interface WritableAtom diff --git a/src/vanilla/store.ts b/src/vanilla/store.ts index 6ccc6fe4a5c..69fd5b005fa 100644 --- a/src/vanilla/store.ts +++ b/src/vanilla/store.ts @@ -789,7 +789,7 @@ export const createStore = (): Store => { (atom, ...params) => atom.read(...params), (atom, ...params) => atom.write(...params), (atom, ...params) => atom.onMount?.(...params), - (store) => (atom) => atom.unstable_onInit?.(store), + (store) => (atom) => atom.INTERNAL_onInit?.(store), ) } diff --git a/tests/vanilla/effect.test.ts b/tests/vanilla/effect.test.ts index 7f1457fb275..72853fd7072 100644 --- a/tests/vanilla/effect.test.ts +++ b/tests/vanilla/effect.test.ts @@ -79,7 +79,7 @@ function atomSyncEffect(effect: Effect) { }, ) bridgeAtom.onMount = (mount) => mount() - bridgeAtom.unstable_onInit = (store) => { + bridgeAtom.INTERNAL_onInit = (store) => { store.get(refAtom).sub = () => { const listener = Object.assign( () => { diff --git a/tests/vanilla/store.test.tsx b/tests/vanilla/store.test.tsx index d95f0f76999..e333ecc11b3 100644 --- a/tests/vanilla/store.test.tsx +++ b/tests/vanilla/store.test.tsx @@ -1010,7 +1010,7 @@ it('should call onInit only once per atom', () => { const store = createStore() const a = atom(0) const onInit = vi.fn() - a.unstable_onInit = onInit + a.INTERNAL_onInit = onInit store.get(a) expect(onInit).toHaveBeenCalledTimes(1) expect(onInit).toHaveBeenCalledWith(store) @@ -1028,10 +1028,10 @@ it('should call onInit only once per atom', () => { it('should call onInit only once per store', () => { const a = atom(0) const aOnInit = vi.fn() - a.unstable_onInit = aOnInit + a.INTERNAL_onInit = aOnInit const b = atom(0) const bOnInit = vi.fn() - b.unstable_onInit = bOnInit + b.INTERNAL_onInit = bOnInit type Store = ReturnType function testInStore(store: Store) { store.get(a) diff --git a/tests/vanilla/unstable_derive.test.tsx b/tests/vanilla/unstable_derive.test.tsx index da3ece10811..cd783f2b7ea 100644 --- a/tests/vanilla/unstable_derive.test.tsx +++ b/tests/vanilla/unstable_derive.test.tsx @@ -186,11 +186,11 @@ it('should pass the correct store instance to the atom initializer', () => { const baseStore = createStore() const derivedStore = baseStore.unstable_derive((...args) => args) const a = atom(null) - a.unstable_onInit = (store) => { + a.INTERNAL_onInit = (store) => { expect(store).toBe(baseStore) } baseStore.get(a) - a.unstable_onInit = (store) => { + a.INTERNAL_onInit = (store) => { expect(store).toBe(derivedStore) } derivedStore.get(a)