diff --git a/src/demos/App.js b/src/demos/App.js index b6889063..8ddc50a2 100644 --- a/src/demos/App.js +++ b/src/demos/App.js @@ -27,10 +27,6 @@ CurrentRecord.propTypes = { record: PropTypes.object, }; -CurrentRecord.defaultProps = { - record: undefined, -}; - class RecordPreviewer extends Component { render() { const { record } = this.props; @@ -42,10 +38,6 @@ RecordPreviewer.propTypes = { record: PropTypes.object, }; -RecordPreviewer.defaultProps = { - record: undefined, -}; - class App extends Component { constructor(props) { super(props); diff --git a/src/lib/elements/ErrorMessage.js b/src/lib/elements/ErrorMessage.js index 50494a6f..04a40815 100644 --- a/src/lib/elements/ErrorMessage.js +++ b/src/lib/elements/ErrorMessage.js @@ -86,11 +86,3 @@ ErrorMessage.propTypes = { content: PropTypes.string, icon: PropTypes.string, }; - -ErrorMessage.defaultProps = { - errors: undefined, - header: undefined, - uiProps: undefined, - icon: undefined, - content: undefined, -}; diff --git a/src/lib/elements/GridResponsiveSidebarColumn.js b/src/lib/elements/GridResponsiveSidebarColumn.js index ff1db613..6bebb937 100644 --- a/src/lib/elements/GridResponsiveSidebarColumn.js +++ b/src/lib/elements/GridResponsiveSidebarColumn.js @@ -79,13 +79,3 @@ GridResponsiveSidebarColumn.propTypes = { widescreen: PropTypes.number, ariaLabel: PropTypes.string, }; - -GridResponsiveSidebarColumn.defaultProps = { - width: undefined, - mobile: undefined, - tablet: undefined, - computer: undefined, - widescreen: undefined, - largeScreen: undefined, - ariaLabel: undefined, -}; diff --git a/src/lib/elements/Image.js b/src/lib/elements/Image.js index 9a7f347a..b206f02a 100644 --- a/src/lib/elements/Image.js +++ b/src/lib/elements/Image.js @@ -15,7 +15,11 @@ import axios from "axios"; */ export class Image extends Component { async componentDidMount() { - const { fallbackSrc, loadFallbackFirst, src } = this.props; + const { + fallbackSrc = "/static/images/square-placeholder.png", + loadFallbackFirst = false, + src, + } = this.props; if (loadFallbackFirst) { try { await axios.get(src); @@ -51,8 +55,14 @@ export class Image extends Component { }; render() { - const { alt, className, src, fallbackSrc, loadFallbackFirst, ...UIprops } = - this.props; + const { + alt = "No image found", + className = "", + src, + fallbackSrc = "/static/images/square-placeholder.png", + loadFallbackFirst = false, + ...UIprops + } = this.props; const loadingClass = !loadFallbackFirst ? `${className} placeholder` : `${className} fallback_image`; @@ -89,10 +99,3 @@ Image.propTypes = { alt: PropTypes.string, loadFallbackFirst: PropTypes.bool, }; - -Image.defaultProps = { - className: "", - alt: "No image found", - fallbackSrc: "/static/images/square-placeholder.png", - loadFallbackFirst: false, -}; diff --git a/src/lib/elements/accessibility/InvenioPopup.js b/src/lib/elements/accessibility/InvenioPopup.js index 74e793bb..fb38686b 100644 --- a/src/lib/elements/accessibility/InvenioPopup.js +++ b/src/lib/elements/accessibility/InvenioPopup.js @@ -12,13 +12,13 @@ export class InvenioPopup extends Component { render() { const { popupId, - size, + size = "small", trigger, content, - position, - inverted, + position = "top left", + inverted = false, ariaLabel, - hoverable, + hoverable = true, } = this.props; return ( @@ -54,10 +54,3 @@ InvenioPopup.propTypes = { position: PropTypes.string, size: PropTypes.string, }; - -InvenioPopup.defaultProps = { - inverted: false, - position: "top left", - size: "small", - hoverable: true, -}; diff --git a/src/lib/elements/bulk_actions/SearchResultsBulkActions.js b/src/lib/elements/bulk_actions/SearchResultsBulkActions.js index 4526c5c9..30a46992 100644 --- a/src/lib/elements/bulk_actions/SearchResultsBulkActions.js +++ b/src/lib/elements/bulk_actions/SearchResultsBulkActions.js @@ -15,7 +15,7 @@ import _pickBy from "lodash/pickBy"; export default class SearchResultsBulkActions extends Component { constructor(props) { super(props); - const { allSelected } = this.props; + const { allSelected = false } = this.props; this.state = { allSelectedChecked: allSelected }; } @@ -86,7 +86,3 @@ SearchResultsBulkActions.propTypes = { allSelected: PropTypes.bool, optionSelectionCallback: PropTypes.func.isRequired, }; - -SearchResultsBulkActions.defaultProps = { - allSelected: false, -}; diff --git a/src/lib/elements/contrib/invenioRDM/users/UserListItemCompact.js b/src/lib/elements/contrib/invenioRDM/users/UserListItemCompact.js index 76a1d4a5..d95aec32 100644 --- a/src/lib/elements/contrib/invenioRDM/users/UserListItemCompact.js +++ b/src/lib/elements/contrib/invenioRDM/users/UserListItemCompact.js @@ -40,7 +40,3 @@ UserListItemCompact.propTypes = { id: PropTypes.string.isRequired, linkToDetailView: PropTypes.string, }; - -UserListItemCompact.defaultProps = { - linkToDetailView: undefined, -}; diff --git a/src/lib/forms/AccordionField.js b/src/lib/forms/AccordionField.js index 546ef8df..2a432b32 100644 --- a/src/lib/forms/AccordionField.js +++ b/src/lib/forms/AccordionField.js @@ -106,7 +106,7 @@ class AccordionError extends Component { render() { const { errors } = this.state; - const { severityChecks } = this.props; + const { severityChecks = null } = this.props; if (errors === undefined) { return null; } @@ -133,14 +133,10 @@ AccordionError.propTypes = { severityChecks: PropTypes.object, }; -AccordionError.defaultProps = { - severityChecks: null, -}; - export class AccordionField extends Component { constructor(props) { super(props); - const { active } = this.props; + const { active = true } = this.props; this.state = { hasError: false, activeIndex: active ? 0 : -1 }; } @@ -155,7 +151,12 @@ export class AccordionField extends Component { }; renderAccordion = (props) => { - const { label, children, includesPaths, severityChecks } = this.props; + const { + label = "", + children = null, + includesPaths = [], + severityChecks = null, + } = this.props; const { hasError, activeIndex } = this.state; // Omit props, so they don't get spread into Accordion https://react.semantic-ui.com/modules/accordion/#types-standard const uiProps = _omit(this.props, [ @@ -207,7 +208,7 @@ export class AccordionField extends Component { }; render() { - const { optimized } = this.props; + const { optimized = false } = this.props; const FormikField = optimized ? FastField : Field; return ; } @@ -222,13 +223,3 @@ AccordionField.propTypes = { ui: PropTypes.object, severityChecks: PropTypes.object, }; - -AccordionField.defaultProps = { - active: true, - includesPaths: [], - label: "", - optimized: false, - children: null, - ui: null, - severityChecks: null, -}; diff --git a/src/lib/forms/ArrayField.js b/src/lib/forms/ArrayField.js index ea6e2765..722831e9 100644 --- a/src/lib/forms/ArrayField.js +++ b/src/lib/forms/ArrayField.js @@ -73,16 +73,16 @@ export class ArrayField extends Component { ...arrayHelpers } = props; const { - addButtonLabel, - addButtonClassName, + addButtonLabel = "Add new row", + addButtonClassName = "align-self-end mt-15", children, defaultNewValue, fieldPath, - label, - labelIcon, - helpText, - requiredOptions, - showEmptyValue, + label = "", + labelIcon = "", + helpText = "", + requiredOptions = [], + showEmptyValue = false, ...uiProps } = this.props; const hasError = this.hasGroupErrors(errors) ? { error: {} } : {}; @@ -160,13 +160,3 @@ ArrayField.propTypes = { requiredOptions: PropTypes.array, showEmptyValue: PropTypes.bool, }; - -ArrayField.defaultProps = { - addButtonLabel: "Add new row", - addButtonClassName: "align-self-end mt-15", - helpText: "", - label: "", - labelIcon: "", - requiredOptions: [], - showEmptyValue: false, -}; diff --git a/src/lib/forms/BaseForm/BaseForm.js b/src/lib/forms/BaseForm/BaseForm.js index 9d8994df..351d022d 100644 --- a/src/lib/forms/BaseForm/BaseForm.js +++ b/src/lib/forms/BaseForm/BaseForm.js @@ -30,7 +30,3 @@ BaseForm.propTypes = { validate: PropTypes.func, }), }; - -BaseForm.defaultProps = { - formik: undefined, -}; diff --git a/src/lib/forms/BooleanField.js b/src/lib/forms/BooleanField.js index a18c5300..47196d6e 100644 --- a/src/lib/forms/BooleanField.js +++ b/src/lib/forms/BooleanField.js @@ -22,7 +22,7 @@ export class BooleanField extends Component { } renderFormField = (props) => { - const { fieldPath, label, ...uiProps } = this.props; + const { fieldPath, label = "", ...uiProps } = this.props; const { form: { values, handleBlur, errors, initialErrors, initialValues, setFieldValue }, } = props; @@ -47,7 +47,7 @@ export class BooleanField extends Component { ); }; render() { - const { optimized, fieldPath } = this.props; + const { optimized = false, fieldPath } = this.props; const FormikField = optimized ? FastField : Field; return ( { - const { fieldPath, injectedError, hasSubfields } = this.props; + const { fieldPath, injectedError, hasSubfields = false } = this.props; let error; if (injectedError) { @@ -64,7 +64,7 @@ export class FeedbackLabel extends Component { }; renderErrors = ({ form: { errors, initialErrors } }) => { - const { fieldPath, pointing } = this.props; + const { fieldPath, pointing = "left" } = this.props; const { error, errMessage, hasSeverity } = this.computeErrors( errors, initialErrors @@ -111,10 +111,3 @@ FeedbackLabel.propTypes = { fieldPath: PropTypes.string, hasSubfields: PropTypes.bool, }; - -FeedbackLabel.defaultProps = { - injectedError: undefined, - pointing: "left", - fieldPath: undefined, - hasSubfields: false, -}; diff --git a/src/lib/forms/FieldLabel.js b/src/lib/forms/FieldLabel.js index 4c375ef7..9c0466ed 100644 --- a/src/lib/forms/FieldLabel.js +++ b/src/lib/forms/FieldLabel.js @@ -12,7 +12,12 @@ import { Icon } from "semantic-ui-react"; export class FieldLabel extends Component { render() { - const { htmlFor, icon, label, className } = this.props; + const { + htmlFor, + icon = "", + label, + className = "field-label-class invenio-field-label", + } = this.props; return (