mirror of
https://github.com/zhigang1992/react.git
synced 2026-03-26 06:55:07 +08:00
docs(use-current-state): add docs for functional initializer mode
fix(dropdown): update layout when mouseenter triggered
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import React, { MutableRefObject, useState } from 'react'
|
||||
import React, { MutableRefObject, useEffect, useState } from 'react'
|
||||
import { createPortal } from 'react-dom'
|
||||
import usePortal from '../utils/use-portal'
|
||||
import useResize from '../utils/use-resize'
|
||||
@@ -57,6 +57,15 @@ const Dropdown: React.FC<React.PropsWithChildren<Props>> = React.memo(
|
||||
useDOMObserver(parent, () => {
|
||||
updateRect()
|
||||
})
|
||||
useEffect(() => {
|
||||
if (!parent || !parent.current) return
|
||||
parent.current.addEventListener('mouseenter', updateRect)
|
||||
/* istanbul ignore next */
|
||||
return () => {
|
||||
if (!parent || !parent.current) return
|
||||
parent.current.removeEventListener('mouseenter', updateRect)
|
||||
}
|
||||
}, [parent])
|
||||
|
||||
const clickHandler = (event: React.MouseEvent<HTMLDivElement>) => {
|
||||
event.stopPropagation()
|
||||
|
||||
Reference in New Issue
Block a user