Skip to content

Commit

Permalink
[Tech debt] Remove defaultProps from function components (elastic#7297
Browse files Browse the repository at this point in the history
)
  • Loading branch information
cee-chen authored Oct 19, 2023
1 parent 0e7f309 commit de10c65
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 44 deletions.
6 changes: 1 addition & 5 deletions src-docs/src/components/guide_rule/guide_rule_example.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const typeToSubtitleTextMap = {
export const GuideRuleExample = ({
children,
className,
type,
type = 'default',
text,
minHeight,
style,
Expand Down Expand Up @@ -103,7 +103,3 @@ GuideRuleExample.propTypes = {
minHeight: PropTypes.number,
panelProps: PropTypes.any,
};

GuideRuleExample.defaultProps = {
type: 'default',
};
10 changes: 0 additions & 10 deletions src-docs/src/views/app_context.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import PropTypes from 'prop-types';
import React, { useContext } from 'react';
import { Helmet } from 'react-helmet';
import { useSelector } from 'react-redux';
Expand Down Expand Up @@ -85,12 +84,3 @@ export const AppContext = ({ children }) => {
</EuiProvider>
);
};

AppContext.propTypes = {
children: PropTypes.any,
currentRoute: PropTypes.object.isRequired,
};

AppContext.defaultProps = {
currentRoute: {},
};
12 changes: 1 addition & 11 deletions src-docs/src/views/app_view.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import PropTypes from 'prop-types';
import React, { useContext } from 'react';
import { useDispatch, useSelector } from 'react-redux';
import { useLocation } from 'react-router-dom';
Expand All @@ -17,7 +16,7 @@ import {
EuiScreenReaderLive,
} from '../../../src/components';

export const AppView = ({ children, currentRoute }) => {
export const AppView = ({ children, currentRoute = {} }) => {
const dispatch = useDispatch();
const toggleLocale = (locale) => dispatch(_toggleLocale(locale));
const locale = useSelector((state) => getLocale(state));
Expand Down Expand Up @@ -65,12 +64,3 @@ export const AppView = ({ children, currentRoute }) => {
</LinkWrapper>
);
};

AppView.propTypes = {
children: PropTypes.any,
currentRoute: PropTypes.object.isRequired,
};

AppView.defaultProps = {
currentRoute: {},
};
10 changes: 2 additions & 8 deletions src/components/form/field_password/field_password.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ export const EuiFieldPassword: FunctionComponent<EuiFieldPasswordProps> = (
value,
isInvalid,
fullWidth = defaultFullWidth,
isLoading,
compressed,
isLoading = false,
compressed = false,
inputRef: _inputRef,
prepend,
append,
Expand Down Expand Up @@ -191,9 +191,3 @@ export const EuiFieldPassword: FunctionComponent<EuiFieldPasswordProps> = (
</EuiFormControlLayout>
);
};

EuiFieldPassword.defaultProps = {
value: undefined,
isLoading: false,
compressed: false,
};
23 changes: 13 additions & 10 deletions src/components/popover/input_popover.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,13 @@ export const EuiInputPopover: FunctionComponent<EuiInputPopoverProps> = ({
children,
className,
closePopover,
anchorPosition = 'downLeft',
attachToAnchor = true,
repositionToCrossAxis = false,
display = 'block',
panelPaddingSize = 's',
closeOnScroll = false,
ownFocus = false,
disableFocusTrap = false,
focusTrapProps,
input,
Expand Down Expand Up @@ -189,15 +195,19 @@ export const EuiInputPopover: FunctionComponent<EuiInputPopoverProps> = ({

return (
<EuiPopover
className={classes}
css={css(fullWidth ? undefined : logicalCSS('max-width', form.maxWidth))}
repositionToCrossAxis={false}
ownFocus={false}
display={display}
button={input}
buttonRef={inputRef}
panelRef={panelRef}
className={classes}
ref={popoverClassRef}
closePopover={closePopover}
anchorPosition={anchorPosition}
attachToAnchor={attachToAnchor}
repositionToCrossAxis={repositionToCrossAxis}
panelPaddingSize={panelPaddingSize}
ownFocus={ownFocus}
{...props}
panelProps={{ ...props.panelProps, onKeyDown }}
>
Expand All @@ -213,10 +223,3 @@ export const EuiInputPopover: FunctionComponent<EuiInputPopoverProps> = ({
</EuiPopover>
);
};

EuiInputPopover.defaultProps = {
anchorPosition: 'downLeft',
attachToAnchor: true,
display: 'block',
panelPaddingSize: 's',
};

0 comments on commit de10c65

Please sign in to comment.