Closed
Description
import { useToggle, useClickAway } from 'ahooks'
import { useRef } from 'react'
import { useClickAway as useClickAway2 } from 'react-use'
function App() {
const [val, { setLeft, setRight }] = useToggle()
return (
<>
<button onClick={setRight}>show</button>
{val && <Comp setLeft={setLeft} />}
</>
)
}
function Comp({ setLeft }) {
const ref = useRef()
useClickAway(() => {
console.log('执行useClickAway')
setLeft()
}, ref)
// useClickAway2(ref, () => {
// console.log('执行useClickAway')
// setLeft()
// })
return (
<div ref={ref} style={{ padding: '50px' }}>
detail
</div>
)
}
export default App
感谢你们的开源 但确实有的被坑到
最简复现如上
换成react-use后正常工作
所以应该不是我的场景问题
Metadata
Metadata
Assignees
Labels
No labels