From b74bd01ca1d300a1dd5ad06f236e5ff0e0bd7578 Mon Sep 17 00:00:00 2001 From: RJ <27843274+rjchow@users.noreply.github.com> Date: Tue, 6 Aug 2024 20:20:45 +0800 Subject: [PATCH] fix: remove defaultProps in prep for react 19 (#50266) --- ...-remove-functional-component-default-props | 4 +++ packages/js/components/src/calendar/input.js | 18 +++------- packages/js/components/src/date/index.js | 13 ++++--- packages/js/components/src/summary/index.js | 10 +++--- packages/js/components/src/summary/number.js | 24 ++++--------- packages/js/components/src/timeline/index.js | 24 ++++++------- .../components/src/timeline/timeline-group.js | 17 ++++----- .../components/src/timeline/timeline-item.js | 9 +---- .../js/components/src/view-more-list/index.js | 6 +--- .../client/activity-panel/activity-panel.js | 6 +--- .../client/activity-panel/panels/help.js | 19 +++++----- .../components/report-table/index.js | 36 +++++++------------ .../homescreen/activity-panel/orders/index.js | 9 ----- .../marketing/coupons/knowledge-base/index.js | 15 +++----- .../coupons/recommended-extensions/index.js | 15 +++----- .../products-control/index.js | 15 +++----- ...-remove-functional-component-default-props | 4 +++ 17 files changed, 86 insertions(+), 158 deletions(-) create mode 100644 packages/js/components/changelog/50266-fix-remove-functional-component-default-props create mode 100644 plugins/woocommerce/changelog/50266-fix-remove-functional-component-default-props diff --git a/packages/js/components/changelog/50266-fix-remove-functional-component-default-props b/packages/js/components/changelog/50266-fix-remove-functional-component-default-props new file mode 100644 index 00000000000..6e876bf13d2 --- /dev/null +++ b/packages/js/components/changelog/50266-fix-remove-functional-component-default-props @@ -0,0 +1,4 @@ +Significance: minor +Type: dev + +Removed defaultProps from React functional components since they will be deprecated for React 19 \ No newline at end of file diff --git a/packages/js/components/src/calendar/input.js b/packages/js/components/src/calendar/input.js index 1b3c433dd18..049b529954b 100644 --- a/packages/js/components/src/calendar/input.js +++ b/packages/js/components/src/calendar/input.js @@ -9,17 +9,17 @@ import { uniqueId, noop } from 'lodash'; import PropTypes from 'prop-types'; const DateInput = ( { - disabled, + disabled = false, value, onChange, dateFormat, label, describedBy, error, - onFocus, - onBlur, - onKeyDown, - errorPosition, + onFocus = () => {}, + onBlur = () => {}, + onKeyDown = noop, + errorPosition = 'bottom center', } ) => { const classes = classnames( 'woocommerce-calendar__input', { 'is-empty': value.length === 0, @@ -73,12 +73,4 @@ DateInput.propTypes = { onKeyDown: PropTypes.func, }; -DateInput.defaultProps = { - disabled: false, - onFocus: () => {}, - onBlur: () => {}, - errorPosition: 'bottom center', - onKeyDown: noop, -}; - export default DateInput; diff --git a/packages/js/components/src/date/index.js b/packages/js/components/src/date/index.js index e67a986039f..281d54ed538 100644 --- a/packages/js/components/src/date/index.js +++ b/packages/js/components/src/date/index.js @@ -15,7 +15,12 @@ import { createElement } from '@wordpress/element'; * @param {string} props.visibleFormat * @return {Object} - */ -const Date = ( { date, machineFormat, screenReaderFormat, visibleFormat } ) => { +const Date = ( { + date, + machineFormat = 'Y-m-d H:i:s', + screenReaderFormat = 'F j, Y', + visibleFormat = 'Y-m-d', +} ) => { return (