UNPKG

@zohodesk/platform-middleware

Version:

Generalized Contract for the events from Marketplace App, In-App widgets, CRM-Plus and EFC

42 lines (33 loc) 952 B
/** Libraries */ import React, { useEffect } from 'react'; import PropTypes from 'prop-types'; var style = { wh100: { width: '100%', height: '100%' } }; var WidgetFrame = function WidgetFrame(props) { var instance = props.instance; var widgetDetails = instance.__WIDGET__; var url = widgetDetails.url, location = widgetDetails.location; var frameRef = React.createRef(); useEffect(function () { var frameInstance = frameRef.current; if (instance && typeof instance.handleLoad === 'function' && frameInstance) { frameInstance.addEventListener('load', instance.handleLoad); } }, []); return React.createElement('iframe', { id: instance._uniqueID, location: location, src: url, ref: frameRef, style: style.wh100 }); }; export default WidgetFrame; WidgetFrame.propTypes = { instance: PropTypes.object };