import React from 'react'; import PropTypes from 'prop-types'; import url from 'url'; export default class AppPermission extends React.Component { constructor(props) { super(props); const curl = this.getCurl(); this.state = { curl: curl, }; console.log('curl', curl); } getCurl() { const wurl = url.parse(this.props.url); let curl; const searchParams = new URLSearchParams(wurl.search); if(searchParams && searchParams.get('url')) { curl = searchParams.get('url'); } curl = curl || wurl; return curl; } render() { return (
Warning
Do you want to load widget from URL?: {this.state.curl}
); } } AppPermission.propTypes = { url: PropTypes.string.isRequired, onPermissionGranted: PropTypes.func.isRequired, }; AppPermission.defaultPropTypes = { onPermissionGranted: function() {}, };