Describe the bug
I have a react component which house the IframeResizer and this component has state based on the event from IframeResizer.
The state supposed to manipulate the latest state with the event but when callback is called I am getting the initial state instead of the latest state which was updated part of last callback.
Now Click on Send message and observe the message that is rendered, empty Height and width
Frame ID: iFrameResizer0 Height: Width: Event type: Message: Hello from the iFrame
Expected behavior
As previous event had those attributes and already saved to the state we should have those values rendered as we are merging new event with the old state.
Describe the bug I have a react component which house the IframeResizer and this component has state based on the event from IframeResizer. The state supposed to manipulate the latest state with the event but when callback is called I am getting the initial state instead of the latest state which was updated part of last callback.
To Reproduce Steps to reproduce the behavior:
const onMessage = data => { setMessageData({...messageData,...data}) ref.current.sendMessage('Hello back from parent page') }
Modify message-data.jsx change renderer
return data ? ( Frame ID: {data.iframe.id} Height: {data.height} Width: {data.width} Event type: {data.type} Message: {data.message}
) : null
Expected behavior As previous event had those attributes and already saved to the state we should have those values rendered as we are merging new event with the old state.
updated Sample code Updated code at
Screenshots If applicable, add screenshots to help explain your problem.
Desktop (please complete the following information):
Smartphone (please complete the following information):