forked from crowetic/commerce
forwardRef
This commit is contained in:
parent
95897aa1c5
commit
3770ad7ea8
@ -7,10 +7,11 @@ interface ClickOutsideProps {
|
|||||||
children: any
|
children: any
|
||||||
}
|
}
|
||||||
|
|
||||||
const ClickOutside = (
|
const ClickOutside = forwardRef(
|
||||||
|
(
|
||||||
{ active = true, onClick, children }: ClickOutsideProps,
|
{ active = true, onClick, children }: ClickOutsideProps,
|
||||||
ref: Ref<HTMLDivElement> | null | any = {}
|
ref: Ref<HTMLDivElement> | null | any = {}
|
||||||
) => {
|
) => {
|
||||||
const innerRef = ref?.current
|
const innerRef = ref?.current
|
||||||
|
|
||||||
const handleClick = (event: any) => {
|
const handleClick = (event: any) => {
|
||||||
@ -38,6 +39,7 @@ const ClickOutside = (
|
|||||||
})
|
})
|
||||||
|
|
||||||
return React.cloneElement(children, { ref })
|
return React.cloneElement(children, { ref })
|
||||||
}
|
}
|
||||||
|
)
|
||||||
|
|
||||||
export default forwardRef(ClickOutside)
|
export default ClickOutside
|
||||||
|
Loading…
x
Reference in New Issue
Block a user