Skip to content

Commit

Permalink
remove defaultProps from functional components
Browse files Browse the repository at this point in the history
  • Loading branch information
rejas committed Aug 19, 2024
1 parent 73fbc31 commit 622be1d
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 48 deletions.
6 changes: 1 addition & 5 deletions packages/components/src/base_tooltip/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import styles from './index.module.scss';

const BaseTooltip = (props) => {
const {
position,
position = 'top',
bubble,
children,
tooltipClassName,
Expand Down Expand Up @@ -57,10 +57,6 @@ const BaseTooltip = (props) => {
);
};

BaseTooltip.defaultProps = {
position: 'top',
};

BaseTooltip.propTypes = {
active: PropTypes.bool,
position: PropTypes.string.isRequired,
Expand Down
12 changes: 3 additions & 9 deletions packages/components/src/cookies_form/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ const CookiesDetails = ({ text }) => (

const CookiesForm = ({
className,
compactView,
defaultModel,
translations,
compactView = false,
defaultModel = {},
translations = {},
onSubmit,
...rest
}) => {
Expand Down Expand Up @@ -71,12 +71,6 @@ const CookiesForm = ({
);
};

CookiesForm.defaultProps = {
compactView: false,
defaultModel: {},
translations: {},
};

CookiesForm.propTypes = {
className: PropTypes.string,
compactView: PropTypes.bool.isRequired,
Expand Down
12 changes: 3 additions & 9 deletions packages/components/src/feature_alert/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ import styles from './index.module.scss';

const FeatureAlertTooltip = (props) => {
const {
position,
position = TOOLTIP_POSITION_LEFT,
trigger,
content,
children,
closeIcon,
defaultOpen,
closeIcon = false,
defaultOpen = false,
onOpen,
onClose,
className,
Expand Down Expand Up @@ -84,12 +84,6 @@ const FeatureAlertTooltip = (props) => {
);
};

FeatureAlertTooltip.defaultProps = {
position: TOOLTIP_POSITION_LEFT,
closeIcon: false,
defaultOpen: false,
};

FeatureAlertTooltip.propTypes = {
className: PropTypes.string,
position: PropTypes.oneOf([
Expand Down
11 changes: 6 additions & 5 deletions packages/components/src/feature_alert_label/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,12 @@ import {
import styles from './index.module.scss';


const FeatureAlertLabel = ({ position, label, children, className, ...cleanProps }) => {
const FeatureAlertLabel = ({
position = TOOLTIP_POSITION_RIGHT,
label,
children,
className,
...cleanProps }) => {
const labelClassName = clsx(styles.label, styles[`is-position-${position}`], className);
return (
<aside {...cleanProps} className={labelClassName}>
Expand All @@ -19,10 +24,6 @@ const FeatureAlertLabel = ({ position, label, children, className, ...cleanProps
);
};

FeatureAlertLabel.defaultProps = {
position: TOOLTIP_POSITION_RIGHT,
};

FeatureAlertLabel.propTypes = {
className: PropTypes.string,
position: PropTypes.oneOf([
Expand Down
7 changes: 1 addition & 6 deletions packages/components/src/logo/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { ReactComponent as CompanyLogo } from './images/logo.svg';
import { ReactComponent as CompanyChristmasLogo } from './images/logo-christmas.svg';

const Logo = (props) => {
const { compact, christmas, to, localeName, children, ...cleanProps } = props;
const { compact = false, christmas = false, to, localeName, children, ...cleanProps } = props;
const className = clsx(styles.root, props.className);
const LogoImage = christmas ? CompanyChristmasLogo : CompanyLogo;

Expand All @@ -28,11 +28,6 @@ const Logo = (props) => {
return <span {...cleanProps} className={className}>{content}</span>;
};

Logo.defaultProps = {
compact: false,
christmas: false,
};

Logo.propTypes = {
className: PropTypes.string,
compact: PropTypes.bool.isRequired,
Expand Down
6 changes: 1 addition & 5 deletions packages/components/src/network_form/network_form.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { useForm } from './hooks';
* @deprecated use app specific Formik based implementation
*/
const NetworkForm = ({
Component,
Component = Form,
getErrorLabel,
onRequest,
onRequestFailure,
Expand Down Expand Up @@ -35,10 +35,6 @@ const NetworkForm = ({
);
};

NetworkForm.defaultProps = {
Component: Form,
};

NetworkForm.propTypes = {
Component: PropTypes.elementType.isRequired,
getErrorLabel: PropTypes.func.isRequired,
Expand Down
12 changes: 3 additions & 9 deletions packages/components/src/progress_line/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import styles from './index.module.scss';
import { PROGRESS_LINE_WEIGHT_NORMAL, PROGRESS_LINE_WEIGHT_THIN } from './constants';

const ProgressLine = ({
steps,
current,
weight,
steps = 1,
current = 0,
weight = PROGRESS_LINE_WEIGHT_NORMAL,
className: passedClassName,
...cleanProps
}) => {
Expand All @@ -28,12 +28,6 @@ const ProgressLine = ({
);
};

ProgressLine.defaultProps = {
steps: 1,
current: 0,
weight: PROGRESS_LINE_WEIGHT_NORMAL,
};

ProgressLine.propTypes = {
className: PropTypes.string,
steps: PropTypes.number.isRequired,
Expand Down

0 comments on commit 622be1d

Please sign in to comment.