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 (