// External Dependencies import React, {Component} from 'react'; // Internal Dependencies import './style.css'; class WpmfFileDesignDivi extends Component { static slug = 'wpmf_file_design'; constructor(props) { super(props); this.state = { html: '', loading: true }; } componentWillMount() { if (typeof this.props.url !== "undefined") { this.loadHtml(this.props); } } componentWillReceiveProps(nextProps) { if (this.props.url !== nextProps.url || this.props.align !== nextProps.align) { this.loadHtml(nextProps); } } loadHtml(props) { if (!this.state.loading) { this.setState({ loading: true }); } fetch(window.et_fb_options.ajaxurl + `?action=wpmf_divi_load_file_design_html&url=${props.url}&align=${props.align}&et_admin_load_nonce=${window.et_fb_options.et_admin_load_nonce}`) .then(res => res.json()) .then( (result) => { this.setState({ html: result.html, loading: false }); }, // errors (error) => { this.setState({ html: '', loading: true }); } ); } render() { const loadingIcon = ( ); if (typeof this.props.url === "undefined") { return (