From c11a1bf5e79b56aa9607b3802e620cb8fd2bf9fd Mon Sep 17 00:00:00 2001 From: David Maskasky Date: Sun, 14 Jul 2024 16:08:51 -0700 Subject: [PATCH] supports: atom toString includes debugLabel in dev mode --- src/utils/useAtomsDevtools.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/utils/useAtomsDevtools.ts b/src/utils/useAtomsDevtools.ts index 1660c658..c214a686 100644 --- a/src/utils/useAtomsDevtools.ts +++ b/src/utils/useAtomsDevtools.ts @@ -8,8 +8,13 @@ import { getReduxExtension } from './redux-extension/getReduxExtension'; import { SnapshotOptions, useAtomsSnapshot } from './useAtomsSnapshot'; import { useGotoAtomsSnapshot } from './useGotoAtomsSnapshot'; -const atomToPrintable = (atom: AnyAtom) => - atom.debugLabel ? `${atom}:${atom.debugLabel}` : `${atom}`; +const atomToPrintable = (atom: AnyAtom) => { + let str = `${atom}`; + if (atom.debugLabel && !str.endsWith(':' + atom.debugLabel)) { + str += ':' + atom.debugLabel; + } + return str; +}; const getDevtoolsState = (atomsSnapshot: AtomsSnapshot) => { const values: Record = {};