Skip to content

Commit 068f64e

Browse files
committed
fix
1 parent e8422e9 commit 068f64e

File tree

4 files changed

+11
-2
lines changed

4 files changed

+11
-2
lines changed

packages/jotai-x/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# jotai-x
22

3+
## 2.1.2
4+
5+
### Patch Changes
6+
7+
- Add `suppressWarnings` option to `createAtomStore` options to control store-level warning behavior when accessing store outside provider
8+
39
## 2.1.1
410

511
### Patch Changes

packages/jotai-x/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "jotai-x",
3-
"version": "2.1.1",
3+
"version": "2.1.2",
44
"description": "Jotai store factory for a best-in-class developer experience.",
55
"license": "MIT",
66
"homepage": "https://jotai-x.udecode.dev/",

packages/jotai-x/src/createAtomStore.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -442,6 +442,7 @@ export interface CreateAtomStoreOptions<
442442
effect?: React.FC;
443443
extend?: (atomsWithoutExtend: StoreAtomsWithoutExtend<T>) => E;
444444
infiniteRenderDetectionLimit?: number;
445+
suppressWarnings?: boolean;
445446
}
446447

447448
/**
@@ -468,6 +469,7 @@ export const createAtomStore = <
468469
effect,
469470
extend,
470471
infiniteRenderDetectionLimit = 100_000,
472+
suppressWarnings,
471473
}: CreateAtomStoreOptions<T, E, N>
472474
): AtomStoreApi<T, E, N> => {
473475
type MyStoreAtoms = StoreAtoms<T, E>;
@@ -524,7 +526,7 @@ export const createAtomStore = <
524526
const {
525527
scope,
526528
store,
527-
warnIfNoStore = true,
529+
warnIfNoStore = !suppressWarnings,
528530
} = convertScopeShorthand(optionsOrScope);
529531
const contextStore = useAtomStore(name, scope, !store && warnIfNoStore);
530532
return store ?? contextStore;

scripts/setupTests.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
import '@testing-library/jest-dom';
22

33
jest.spyOn(global.console, 'warn').mockImplementation(() => jest.fn());
4+
jest.spyOn(global.console, 'error').mockImplementation(() => jest.fn());

0 commit comments

Comments
 (0)