/** * External dependencies */ import { __ } from '@wordpress/i18n'; import PropTypes from 'prop-types'; import { Icon, commentContent, external } from '@wordpress/icons'; import { useEffect, useState } from '@wordpress/element'; /** * Internal dependencies */ import './style.scss'; /** * Component to render a Feedback prompt in the sidebar. * * @param {Object} props Incoming props for the component. * @param {string} props.text * @param {string} props.url */ const FeedbackPrompt = ( { text, url = 'https://ideas.woocommerce.com/forums/133476-woocommerce?category_id=384565', } ) => { // By returning false we ensure that this component is not entered into the InspectorControls // (which is a slot fill), children array on first render, on the second render when the state // gets updated this component does get put into the InspectorControls children array but as the // last item, ensuring it shows last in the sidebar. const [ isVisible, setIsVisible ] = useState( false ); useEffect( () => { setIsVisible( true ); }, [] ); return ( isVisible && (
{ text }
{ __( 'Give us your feedback.', 'woo-gutenberg-products-block' ) }