mirror of
https://github.com/pmndrs/zustand.git
synced 2025-12-08 19:45:52 +00:00
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:
parent
a6143e0f23
commit
ca08a5ebf9
@ -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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user