Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Tech debt] Remove defaultProps from function components #7297

Merged
merged 4 commits into from
Oct 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,
};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did we lose this or is it just no longer neccessary?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not necessary - it wasn't even being used, so my guess was it was a bad copy/paste job


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',
};
Loading