From 13d4be3d7a5627c961f431408db5eaa8be420707 Mon Sep 17 00:00:00 2001 From: artalar Date: Sun, 8 Dec 2024 13:58:30 +0300 Subject: [PATCH] fix(npm-react): use named function in reatomComponent --- packages/npm-react/src/index.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/npm-react/src/index.ts b/packages/npm-react/src/index.ts index 0d349aa1..c5813c4d 100644 --- a/packages/npm-react/src/index.ts +++ b/packages/npm-react/src/index.ts @@ -57,6 +57,8 @@ export const withBatching = (ctx: Ctx): Ctx => { } } +const anonFnName = (() => () => {})().name + export const reatomContext = React.createContext(null) export const useCtx = (): Ctx => { @@ -217,6 +219,7 @@ export const reatomComponent = ( name?: string, ): ((props: T extends PropsWithCtx ? P : T) => JSX.Element) => { if (name) name = `Component.${name}` + else if (Component.name !== anonFnName) name = Component.name else name = __count('Component') let rendering = false