Skip to content

Commit

Permalink
Merge pull request #864 from CodeForAfrica/chore/climatemappedafrica-…
Browse files Browse the repository at this point in the history
…remove-default-props

@/climatemappedafrica - chore: remove defaultProps in functional components
  • Loading branch information
m453h authored Aug 30, 2024
2 parents 88ef978 + 66f65ba commit 1daa3e4
Show file tree
Hide file tree
Showing 36 changed files with 16 additions and 270 deletions.
16 changes: 3 additions & 13 deletions apps/climatemappedafrica/src/components/DropdownSearch/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,11 @@ const useStyles = makeStyles(({ palette, typography }) => ({
}));

function DropdownSearch({
href: hrefProp,
label,
href: hrefProp = "/explore",
label = "Search for a location",
counties,
onClick,
icon: iconProp,
icon: iconProp = SearchIcon,
placeholder,
variant,
...props
Expand Down Expand Up @@ -176,14 +176,4 @@ DropdownSearch.propTypes = {
placeholder: PropTypes.string,
};

DropdownSearch.defaultProps = {
label: "Search for a location",
href: "/explore",
onClick: undefined,
icon: SearchIcon,
counties: undefined,
variant: undefined,
placeholder: undefined,
};

export default DropdownSearch;
8 changes: 1 addition & 7 deletions apps/climatemappedafrica/src/components/ExplorePage/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ function initialState(profiles, onClick) {
};
}

function ExplorePage({ panelProps, profile: profileProp, ...props }) {
function ExplorePage({ panelProps, profile: profileProp, apiUri, ...props }) {
const theme = useTheme();
const classes = useStyles(props);
// NOTE: This setState and the corresponding useEffect are "hacks" since at
Expand Down Expand Up @@ -186,10 +186,4 @@ ExplorePage.propTypes = {
]),
};

ExplorePage.defaultProps = {
apiUri: undefined,
panelProps: undefined,
profile: undefined,
};

export default ExplorePage;
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,4 @@ CategoryHeader.propTypes = {
icon: PropTypes.string,
};

CategoryHeader.defaultProps = {
title: undefined,
description: undefined,
icon: undefined,
};

export default CategoryHeader;
Original file line number Diff line number Diff line change
Expand Up @@ -164,12 +164,4 @@ Filters.propTypes = {
}),
};

Filters.defaultProps = {
defaultFilters: undefined,
filterGroups: undefined,
filterSelectProps: undefined,
setFilterSelectProps: undefined,
view: undefined,
};

export default Filters;
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ function ChartFilter({
onSelectAttribute,
deleteFilter,
index,
attributeText,
valueText,
attributeText = "Filter by attribute:",
valueText = "Select a value:",
selectedAttribute: selectedAttributeProp,
selectedValue: selectedValueProp,
...props
Expand Down Expand Up @@ -161,8 +161,6 @@ ChartFilter.defaultProps = {
onSelectAttribute: undefined,
selectedValue: undefined,
selectedAttribute: undefined,
attributeText: "Filter by attribute:",
valueText: "Select a value:",
};

export default ChartFilter;
13 changes: 0 additions & 13 deletions apps/climatemappedafrica/src/components/HURUmap/KeyMetric/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,17 +94,4 @@ KeyMetric.propTypes = {
parentFormattedValue: PropTypes.string,
};

KeyMetric.defaultProps = {
className: undefined,
color: undefined,
description: undefined,
displayFormat: undefined,
formattedValue: undefined,
metadata: undefined,
title: undefined,
value: undefined,
parentName: undefined,
parentFormattedValue: undefined,
};

export default KeyMetric;
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,4 @@ LocationHeader.propTypes = {
title: PropTypes.string,
};

LocationHeader.defaultProps = {
icon: undefined,
level: undefined,
onClick: undefined,
parent: undefined,
title: undefined,
};

export default LocationHeader;
Original file line number Diff line number Diff line change
Expand Up @@ -171,15 +171,4 @@ PanelButtons.propTypes = {
}),
};

PanelButtons.defaultProps = {
drawerRef: undefined,
isCompare: undefined,
isPinning: undefined,
onClickPin: undefined,
onClickUnpin: undefined,
panelItems: undefined,
primaryProfile: undefined,
secondaryProfile: undefined,
};

export default PanelButtons;
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,4 @@ PanelItem.propTypes = {
}),
};

PanelItem.defaultProps = {
item: undefined,
};

export default PanelItem;
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,4 @@ RichData.propTypes = {
}),
};

RichData.defaultProps = {
primaryProfile: undefined,
};

export default RichData;
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,4 @@ DesktopPanel.propTypes = {
}),
};

DesktopPanel.defaultProps = {
isCompare: undefined,
isPinning: undefined,
onClickPin: undefined,
onClickUnpin: undefined,
panelItems: undefined,
primaryProfile: undefined,
};

export default DesktopPanel;
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import SubcategoryList from "./SubcategoryList";

import Profile from "@/climatemappedafrica/components/HURUmap/Panel/Profile";

function RichData({ item, ...props }) {
function RichData({ item, geography, ...props }) {
return (
<>
<SubcategoryList items={item.children} />
Expand All @@ -26,9 +26,4 @@ RichData.propTypes = {
}),
};

RichData.defaultProps = {
item: undefined,
geography: undefined,
};

export default RichData;
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,4 @@ SubcategoryList.propTypes = {
items: PropTypes.arrayOf(PropTypes.shape({})),
};

SubcategoryList.defaultProps = {
items: undefined,
};

export default SubcategoryList;
Original file line number Diff line number Diff line change
Expand Up @@ -112,12 +112,4 @@ MobilePanel.propTypes = {
scrollToTopLabel: PropTypes.string,
};

MobilePanel.defaultProps = {
activeType: undefined,
dataNotAvailable: undefined,
onSelectLocation: undefined,
primaryProfile: undefined,
scrollToTopLabel: undefined,
};

export default MobilePanel;
12 changes: 0 additions & 12 deletions apps/climatemappedafrica/src/components/HURUmap/Panel/Profile.js
Original file line number Diff line number Diff line change
Expand Up @@ -195,16 +195,4 @@ Profile.propTypes = {
}),
};

Profile.defaultProps = {
categories: undefined,
dataNotAvailable: undefined,
isLoading: undefined,
isPinning: undefined,
onClickPin: undefined,
onClickUnpin: undefined,
onSelectLocation: undefined,
primaryProfile: undefined,
secondaryProfile: undefined,
};

export default Profile;
Original file line number Diff line number Diff line change
Expand Up @@ -252,14 +252,4 @@ ProfileItems.propTypes = {
}),
};

ProfileItems.defaultProps = {
categories: undefined,
dataNotAvailable: undefined,
getSecondaryIndicator: undefined,
getSecondaryMetric: undefined,
geoCode: undefined,
primaryProfile: undefined,
secondaryProfile: undefined,
};

export default ProfileItems;
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import React from "react";

import useStyles from "./useStyles";

function PanelButtonGroup({ items, value, onChange, pins, ...props }) {
function PanelButtonGroup({ items, value, onChange, pins = [], ...props }) {
const classes = useStyles(props);
const handleChange = (_, selected) => {
onChange(selected);
Expand Down Expand Up @@ -63,11 +63,4 @@ PanelButtonGroup.propTypes = {
onChange: PropTypes.func,
};

PanelButtonGroup.defaultProps = {
pins: [],
items: undefined,
value: undefined,
onChange: undefined,
};

export default PanelButtonGroup;
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ function PinIcon(props) {

function PinAndCompare({
helperText,
isMobile,
isMobile = false,
currentGeographyCode,
locations,
onChange,
onClose,
onClickPin,
onClose,
placeholder,
...props
}) {
Expand Down Expand Up @@ -110,15 +110,4 @@ PinAndCompare.propTypes = {
placeholder: PropTypes.string,
};

PinAndCompare.defaultProps = {
helperText: undefined,
isMobile: false,
currentGeographyCode: undefined,
locations: undefined,
onChange: undefined,
onClickPin: undefined,
onClose: undefined,
placeholder: undefined,
};

export default PinAndCompare;
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,4 @@ SubcategoryHeader.propTypes = {
description: PropTypes.string,
};

SubcategoryHeader.defaultProps = {
title: undefined,
description: undefined,
};

export default SubcategoryHeader;
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,4 @@ TreeView.propTypes = {
onLabelClick: PropTypes.func,
};

TreeView.defaultProps = {
items: undefined,
onLabelClick: undefined,
};

export default TreeView;
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,4 @@ TutorialStep.propTypes = {
selector: PropTypes.string,
};

TutorialStep.defaultProps = {
description: undefined,
image: undefined,
onClose: undefined,
title: undefined,
selector: undefined,
};

export default TutorialStep;
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const useStyles = makeStyles(({ typography, palette }) => ({
},
}));

function Tutorial({ children, defaultOpen, items, ...props }) {
function Tutorial({ children, defaultOpen = false, items, ...props }) {
const classes = useStyles(props);
const { setIsOpen } = useTour();
setIsOpen(defaultOpen);
Expand Down Expand Up @@ -80,10 +80,4 @@ Tutorial.propTypes = {
defaultOpen: PropTypes.bool,
};

Tutorial.defaultProps = {
items: undefined,
children: undefined,
defaultOpen: false,
};

export default Tutorial;
5 changes: 0 additions & 5 deletions apps/climatemappedafrica/src/components/Image/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,4 @@ Image.propTypes = {
src: PropTypes.oneOfType([PropTypes.shape({}), PropTypes.string]),
};

Image.defaultProps = {
placeholder: undefined,
src: undefined,
};

export default Image;
22 changes: 0 additions & 22 deletions apps/climatemappedafrica/src/components/Link/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,18 +52,6 @@ NextComposed.propTypes = {
shallow: PropTypes.bool,
};

NextComposed.defaultProps = {
as: undefined,
component: undefined,
href: undefined,
locale: undefined,
passHref: undefined,
prefetch: undefined,
replace: undefined,
scroll: undefined,
shallow: undefined,
};

// A styled version of the Next.js Link component:
// https://nextjs.org/docs/api-reference/next/link/
const Link = forwardRef(function Link(props, ref) {
Expand Down Expand Up @@ -142,14 +130,4 @@ Link.propTypes = {
prefetch: PropTypes.bool,
};

Link.defaultProps = {
activeClassName: undefined,
as: undefined,
className: undefined,
href: undefined,
naked: undefined,
onClick: undefined,
prefetch: undefined,
};

export default Link;
Loading

0 comments on commit 1daa3e4

Please sign in to comment.