From e10edc827e4916aa06a8fcc38fd7dcfde2b4d7c2 Mon Sep 17 00:00:00 2001 From: David Maskasky Date: Sun, 14 Jul 2024 15:56:39 -0700 Subject: [PATCH] atom toString includes debugLabel in dev mode --- src/vanilla/atom.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/vanilla/atom.ts b/src/vanilla/atom.ts index b2cfcba268..27795d4f06 100644 --- a/src/vanilla/atom.ts +++ b/src/vanilla/atom.ts @@ -92,7 +92,11 @@ export function atom( ) { const key = `atom${++keyCount}` const config = { - toString: () => key, + toString() { + return import.meta.env?.MODE !== 'production' && this.debugLabel + ? key + ':' + this.debugLabel + : key + }, } as WritableAtom & { init?: Value } if (typeof read === 'function') { config.read = read as Read>