iframe-resizer
iframe-resizer copied to clipboard
onMessage handler not getting any data in IframeResizer in reactjs ?
import React, {useEffect, useRef, useState} from "react";
import IframeResizer from 'iframe-resizer-react'
export default()=>{
const ref = useRef(null);
const [message, setMessage] = useState("default");
const onMessage = (msg)=>{
// Not able to receive any data
setMessage(msg)
}
return <>
<IframeResizer
forwardRef={ref}
log
src="link"
onMessage={onMessage}
/>
<p>{message}</p>
</>
}
onMessage handler is not triggering when something sends back to parent from src link but its working fine with window.addEventListner "message" in useEffect,
The source link is simple webpage that return data if we click on button located in it. window.addEventLisnter ("message" is working fine in useEffect, but i want to use onMessage to get the message. Suggestions/solutions are highly appreciable.
I am facing the same issue, any update/fix/workaround for this yet?
Fixed in V5.0.0
Please see https://iframe-resizer.com/frameworks/react/#advanced-example