Skip to content

Commit

Permalink
chore: 抽离onLayout钩子
Browse files Browse the repository at this point in the history
  • Loading branch information
lareinayanyu committed Oct 17, 2024
1 parent 59450c6 commit b3f62be
Showing 1 changed file with 0 additions and 16 deletions.
16 changes: 0 additions & 16 deletions packages/webpack-plugin/lib/runtime/components/react/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -451,19 +451,3 @@ export function splitProps<T extends Record<string, any>> (props: T): {
innerProps: Partial<T>;
}
}

export const useLayoutHook = ({ hasSelfPercent, enableOffset, setWidth, setHeight, layoutRef, nodeRef }, callback) => {
return (e: LayoutChangeEvent) => {
if (hasSelfPercent) {
const { width, height } = e?.nativeEvent?.layout || {}
setWidth(width || 0)
setHeight(height || 0)
}
if (enableOffset) {
nodeRef.current?.measure((x: number, y: number, width: number, height: number, offsetLeft: number, offsetTop: number) => {
layoutRef.current = { x, y, width, height, offsetLeft, offsetTop }
})
}
callback && callback(e)
}
}

0 comments on commit b3f62be

Please sign in to comment.