Skip to content

Commit

Permalink
fix: warning from FormikControl with blank help={...}
Browse files Browse the repository at this point in the history
  • Loading branch information
bradenmacdonald committed Sep 13, 2024
1 parent 104fce1 commit 0546f23
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 28 deletions.
39 changes: 14 additions & 25 deletions src/generic/FormikControl.jsx → src/generic/FormikControl.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,24 @@
/* eslint-disable react/jsx-no-useless-fragment */
import { Form } from '@openedx/paragon';
import { getIn, useFormikContext } from 'formik';
import PropTypes from 'prop-types';
import React from 'react';
import FormikErrorFeedback from './FormikErrorFeedback';

const FormikControl = ({
interface Props {
name: string;
label?: React.ReactElement;
help?: React.ReactElement;
className?: string;
controlClasses?: string;
value: string | number;
}

const FormikControl: React.FC<Props & React.ComponentProps<typeof Form.Control>> = ({
name,
label,
help,
className,
controlClasses,
label = <></>,
help = <></>,
className = '',
controlClasses = 'pb-2',
...params
}) => {
const {
Expand Down Expand Up @@ -39,23 +47,4 @@ const FormikControl = ({
);
};

FormikControl.propTypes = {
name: PropTypes.string.isRequired,
label: PropTypes.element,
help: PropTypes.element,
className: PropTypes.string,
controlClasses: PropTypes.string,
value: PropTypes.oneOfType([
PropTypes.string,
PropTypes.number,
]).isRequired,
};

FormikControl.defaultProps = {
help: <></>,
label: <></>,
className: '',
controlClasses: 'pb-2',
};

export default FormikControl;
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,6 @@ const CreateCollectionModal = () => {
)}
value={formikProps.values.title}
placeholder={intl.formatMessage(messages.createCollectionModalNamePlaceholder)}
help={null}
className=""
controlClasses="pb-2"
/>
<FormikControl
Expand All @@ -98,7 +96,6 @@ const CreateCollectionModal = () => {
{intl.formatMessage(messages.createCollectionModalDescriptionDetails)}
</Form.Text>
)}
className=""
controlClasses="pb-2"
rows="5"
/>
Expand Down

0 comments on commit 0546f23

Please sign in to comment.