8000 refactor: remove duplicated code · engrrio07/coreui-react-17@1644697 · GitHub
[go: up one dir, main page]

Skip to content

Commit 1644697

Browse files
committed
refactor: remove duplicated code
1 parent a432e2e commit 1644697

File tree

1 file changed

+14
-20
lines changed

1 file changed

+14
-20
lines changed

packages/coreui-react/src/components/form/CFormControlWrapper.tsx

Lines changed: 14 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -57,37 +57,31 @@ export const CFormControlWrapper: FC<CFormControlWrapperProps> = ({
5757
tooltipFeedback,
5858
valid,
5959
}) => {
60+
const formControlValidation = () => (
61+
<CFormControlValidation
62+
describedby={describedby}
63+
feedback={feedback}
64+
feedbackInvalid={feedbackInvalid}
65+
feedbackValid={feedbackValid}
66+
floatingLabel={floatingLabel}
67+
invalid={invalid}
68+
tooltipFeedback={tooltipFeedback}
69+
valid={valid}
70+
/>
71+
)
6072
return floatingLabel ? (
6173
<CFormFloating className={floatingClassName}>
6274
{children}
6375
<CFormLabel htmlFor={id}>{label || floatingLabel}</CFormLabel>
6476
{text && <CFormText id={describedby}>{text}</CFormText>}
65-
<CFormControlValidation
66-
describedby={describedby}
67-
feedback={feedback}
68-
feedbackInvalid={feedbackInvalid}
69-
feedbackValid={feedbackValid}
70-
floatingLabel={floatingLabel}
71-
invalid={invalid}
72-
tooltipFeedback={tooltipFeedback}
73-
valid={valid}
74-
/>
77+
{formControlValidation()}
7578
</CFormFloating>
7679
) : (
7780
<>
7881
{label && <CFormLabel htmlFor={id}>{label}</CFormLabel>}
7982
{children}
8083
{text && <CFormText id={describedby}>{text}</CFormText>}
81-
<CFormControlValidation
82-
describedby={describedby}
83-
feedback={feedback}
84-
feedbackInvalid={feedbackInvalid}
85-
feedbackValid={feedbackValid}
86-
floatingLabel={floatingLabel}
87-
invalid={invalid}
88-
tooltipFeedback={tooltipFeedback}
89-
valid={valid}
90-
/>
84+
{formControlValidation()}
9185
</>
9286
)
9387
}

0 commit comments

Comments
 (0)
0