Forward ref in Popup component
This commit is contained in:
@@ -1,9 +1,9 @@
|
|||||||
import React, { useEffect, useRef } from "react"
|
import React, { useEffect, useRef, forwardRef } from "react"
|
||||||
import PropTypes from "prop-types"
|
import PropTypes from "prop-types"
|
||||||
import queryString from "query-string"
|
import queryString from "query-string"
|
||||||
import { serializeProps } from "utils"
|
import { serializeProps } from "utils"
|
||||||
|
|
||||||
function Popup(props) {
|
const Popup = forwardRef((props, ref) => {
|
||||||
const iFrameRef = useRef()
|
const iFrameRef = useRef()
|
||||||
|
|
||||||
const handleRequestClose = event => {
|
const handleRequestClose = event => {
|
||||||
@@ -49,7 +49,7 @@ function Popup(props) {
|
|||||||
])(props)
|
])(props)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="moco-bx-popup" onClick={handleRequestClose}>
|
<div ref={ref} className="moco-bx-popup" onClick={handleRequestClose}>
|
||||||
<div className="moco-bx-popup-content" style={{ width: "516px", minHeight: "300px" }}>
|
<div className="moco-bx-popup-content" style={{ width: "516px", minHeight: "300px" }}>
|
||||||
<iframe
|
<iframe
|
||||||
ref={iFrameRef}
|
ref={iFrameRef}
|
||||||
@@ -59,7 +59,9 @@ function Popup(props) {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
})
|
||||||
|
|
||||||
|
Popup.displayName = "Popup"
|
||||||
|
|
||||||
Popup.propTypes = {
|
Popup.propTypes = {
|
||||||
service: PropTypes.object,
|
service: PropTypes.object,
|
||||||
|
|||||||
Reference in New Issue
Block a user