Skip to content

Commit

Permalink
atom toString includes debugLabel in dev mode (#2659)
Browse files Browse the repository at this point in the history
Co-authored-by: Daishi Kato <dai-shi@users.noreply.github.com>
  • Loading branch information
dmaskasky and dai-shi authored Jul 23, 2024
1 parent 628aa3e commit 27117bf
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/vanilla/atom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,11 @@ export function atom<Value, Args extends unknown[], Result>(
) {
const key = `atom${++keyCount}`
const config = {
toString: () => key,
toString() {
return import.meta.env?.MODE !== 'production' && this.debugLabel
? key + ':' + this.debugLabel
: key
},
} as WritableAtom<Value, Args, Result> & { init?: Value }
if (typeof read === 'function') {
config.read = read as Read<Value, SetAtom<Args, Result>>
Expand Down

0 comments on commit 27117bf

Please sign in to comment.