perf(devtools): avoid inferring action type when explicit action name is provided (#3147)

Co-authored-by: Daishi Kato <dai-shi@users.noreply.github.com>
This commit is contained in:
Vladimir Chirikov 2025-06-23 06:17:41 +03:00 committed by GitHub
parent a6143e0f23
commit ca08a5ebf9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -207,10 +207,14 @@ const devtoolsImpl: DevtoolsImpl =
;(api.setState as any) = ((state, replace, nameOrAction: Action) => {
const r = set(state, replace as any)
if (!isRecording) return r
const inferredActionType = findCallerName(new Error().stack)
const action: { type: string } =
nameOrAction === undefined
? { type: anonymousActionType || inferredActionType || 'anonymous' }
? {
type:
anonymousActionType ||
findCallerName(new Error().stack) ||
'anonymous',
}
: typeof nameOrAction === 'string'
? { type: nameOrAction }
: nameOrAction