I have a page that opens a new window and sends a message with window.open and window.postMessage. All is well and good there, however, I am trying to get the PropType validation for the window working.
The error I am getting is:
Warning: Failed prop type: Invalid prop newWindow
of type Window
supplied to ButtonsObj
, expected instance of Window
.
The issue is the same as here, unfortunately the provided answer doesn't seem to work. How do I include window as a valid prop with PropTypes?
// From ButtonsObj component class
openInNewTabWPeriods() {
const win = window.open('management/new_window', 'NewWindow');
window.addEventListener('message', this.sendUUIDs, false);
this.props.dispatch({
type: 'NEW_WINDOW',
win,
});
}
ButtonsObj.propTypes = {
newWindow: PropTypes.instanceOf(window.constructor).isRequired,
};
// from the reducer
initialState = { newWindow: window.window };
With the initialState, I've also tried null, but that gives the following warning:
Warning: Failed prop type: The prop newWindow
is marked as required in ButtonsObj
, but its value is null
.