From c9b551936a0c2eae762382fba78bd5499d3caee4 Mon Sep 17 00:00:00 2001 From: Claudia Malzer <42971992+CalamityC@users.noreply.github.com> Date: Wed, 19 Jun 2024 11:48:36 +0200 Subject: [PATCH] ERM-3273 React v19: refactor stripes-erm-components away from default props for functional components (#686) * set default values directly in the prop statements of components Co-authored-by: EthanFreestone <54310740+EthanFreestone@users.noreply.github.com> --- .../CustomMetaSectionHeader.js | 30 +++++++++---------- .../DocumentsFieldArray.js | 12 ++------ .../InternalContactsFieldArray.js | 9 ++---- 3 files changed, 20 insertions(+), 31 deletions(-) diff --git a/lib/CustomMetaSection/CustomMetaSectionHeader.js b/lib/CustomMetaSection/CustomMetaSectionHeader.js index 40231fec..b4aad845 100644 --- a/lib/CustomMetaSection/CustomMetaSectionHeader.js +++ b/lib/CustomMetaSection/CustomMetaSectionHeader.js @@ -15,36 +15,37 @@ const propTypes = { open: PropTypes.bool, }; -const defaultProps = { - headingLevel: 4 -}; - -const CustomMetaAccordionHeader = (props) => { +const CustomMetaAccordionHeader = ({ + contentId, + displayWhenClosed, + displayWhenOpen, + headingLevel = 4, + id, + label, + onToggle, + open +}) => { let toggleElem = null; let labelElem = null; let containerElem = null; function handleHeaderClick(e) { - const { id, label } = props; - props.onToggle({ id, label }); + onToggle({ id, label }); e.stopPropagation(); } function handleKeyPress(e) { e.preventDefault(); - if (e.charCode === 13 || e.charCode === 32) { // enter key or space key... + if (e.charCode === 13 || e.charCode === 32) { // enter key or space key if (e.target === toggleElem || e.target === labelElem || e.target === containerElem) { - const { id, label } = props; - props.onToggle({ id, label }); + onToggle({ id, label }); } } } - const { label, open, displayWhenOpen, displayWhenClosed, contentId } = props; - return (
{ containerElem = ref; }} className={css.headerWrapper}> - +