Convert `edit.js` to `edit.tsx` and replace `propTypes` with TypeScript definitions (https://github.com/woocommerce/woocommerce-blocks/pull/9823)
* Remove proptypes * Refactor after review
This commit is contained in:
parent
2460a04abd
commit
8a67ae2f80
|
@ -10,9 +10,8 @@ import {
|
|||
withSpokenMessages,
|
||||
} from '@wordpress/components';
|
||||
import { SearchListItem } from '@woocommerce/editor-components/search-list-control';
|
||||
import PropTypes from 'prop-types';
|
||||
import ProductControl from '@woocommerce/editor-components/product-control';
|
||||
import { Icon, commentContent } from '@wordpress/icons';
|
||||
import { commentContent, Icon } from '@wordpress/icons';
|
||||
|
||||
/**
|
||||
* Internal dependencies
|
||||
|
@ -24,20 +23,13 @@ import {
|
|||
getSharedReviewContentControls,
|
||||
getSharedReviewListControls,
|
||||
} from '../edit-utils.js';
|
||||
import { ReviewsByProductEditorProps } from './types';
|
||||
|
||||
/**
|
||||
* Component to handle edit mode of "Reviews by Product".
|
||||
*
|
||||
* @param {Object} props Incoming props for the component.
|
||||
* @param {Object} props.attributes Incoming block attributes.
|
||||
* @param {function(any):any} props.debouncedSpeak
|
||||
* @param {function(any):any} props.setAttributes Setter for block attributes.
|
||||
*/
|
||||
const ReviewsByProductEditor = ( {
|
||||
attributes,
|
||||
debouncedSpeak,
|
||||
setAttributes,
|
||||
} ) => {
|
||||
}: ReviewsByProductEditorProps ) => {
|
||||
const { editMode, productId } = attributes;
|
||||
|
||||
const renderProductControlItem = ( args ) => {
|
||||
|
@ -189,21 +181,4 @@ const ReviewsByProductEditor = ( {
|
|||
);
|
||||
};
|
||||
|
||||
ReviewsByProductEditor.propTypes = {
|
||||
/**
|
||||
* The attributes for this block.
|
||||
*/
|
||||
attributes: PropTypes.object.isRequired,
|
||||
/**
|
||||
* The register block name.
|
||||
*/
|
||||
name: PropTypes.string.isRequired,
|
||||
/**
|
||||
* A callback to update attributes.
|
||||
*/
|
||||
setAttributes: PropTypes.func.isRequired,
|
||||
// from withSpokenMessages
|
||||
debouncedSpeak: PropTypes.func.isRequired,
|
||||
};
|
||||
|
||||
export default withSpokenMessages( ReviewsByProductEditor );
|
|
@ -0,0 +1,15 @@
|
|||
/**
|
||||
* External dependencies
|
||||
*/
|
||||
import { BlockEditProps } from '@wordpress/blocks';
|
||||
|
||||
interface ReviewByProductAttributes {
|
||||
editMode: boolean;
|
||||
productId: number;
|
||||
}
|
||||
|
||||
export interface ReviewsByProductEditorProps
|
||||
extends BlockEditProps< ReviewByProductAttributes > {
|
||||
attributes: ReviewByProductAttributes;
|
||||
debouncedSpeak: ( message: string ) => void;
|
||||
}
|
Loading…
Reference in New Issue