Skip to content

Commit

Permalink
fix: 优化通用事件handler为undefined属性透传问题
Browse files Browse the repository at this point in the history
  • Loading branch information
lareinayanyu committed Nov 5, 2024
1 parent 2c56aa9 commit 88ceef0
Showing 1 changed file with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { useRef } from 'react'
import { hasOwn } from '@mpxjs/utils'
import { omit, extendObject } from './utils'
import eventConfigMap from './event.config'
import {
Expand Down Expand Up @@ -148,7 +149,7 @@ const useInnerProps = (
propsRef.current = extendObject(props, additionalProps)

for (const key in eventConfigMap) {
if (propsRef.current[key]) {
if (hasOwn(propsRef.current, key)) {
eventConfig[key] = eventConfigMap[key]
}
}
Expand Down Expand Up @@ -291,9 +292,11 @@ const useInnerProps = (

const events: Record<string, (e: NativeTouchEvent) => void> = {}

const transformedEventKeys: string[] = []
let transformedEventKeys: string[] = []
for (const key in eventConfig) {
transformedEventKeys.concat(eventConfig[key])
if (propsRef.current[key]) {
transformedEventKeys = transformedEventKeys.concat(eventConfig[key])
}
}

const finalEventKeys = [...new Set(transformedEventKeys)]
Expand Down

0 comments on commit 88ceef0

Please sign in to comment.