Skip to content

Commit 27117bf

Browse files
David Maskaskydai-shi
andauthored
atom toString includes debugLabel in dev mode (#2659)
Co-authored-by: Daishi Kato <[email protected]>
1 parent 628aa3e commit 27117bf

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/vanilla/atom.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,11 @@ export function atom<Value, Args extends unknown[], Result>(
9292
) {
9393
const key = `atom${++keyCount}`
9494
const config = {
95-
toString: () => key,
95+
toString() {
96+
return import.meta.env?.MODE !== 'production' && this.debugLabel
97+
? key + ':' + this.debugLabel
98+
: key
99+
},
96100
} as WritableAtom<Value, Args, Result> & { init?: Value }
97101
if (typeof read === 'function') {
98102
config.read = read as Read<Value, SetAtom<Args, Result>>

0 commit comments

Comments
 (0)