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

Remove default props from functional components #1906

Merged
merged 10 commits into from
May 20, 2024
1 change: 1 addition & 0 deletions RELEASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ Please follow the established format:
- Enhance kedro-viz doc integration. (#1874)
- Fix Kedro-Viz waiting for valid Kedro project. (#1871)
- Enhance Kedro-Viz documentation by using Kedro-sphinx-theme. (#1898)
- Remove default props from functional components. (#1906)

# Release 9.0.0

Expand Down
17 changes: 8 additions & 9 deletions src/components/ui/button/button.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,14 @@ import './button.scss';
/**
* Generic Kedro Button
*/
const Button = ({ children, dataTest, disabled, onClick, size, mode }) => (
const Button = ({
children,
dataTest = 'TestDefaultDataValue',
disabled = false,
onClick,
size = 'regular',
mode = 'primary',
}) => (
<span className="kedro button">
<button
className={classnames(
Expand All @@ -23,14 +30,6 @@ const Button = ({ children, dataTest, disabled, onClick, size, mode }) => (
</span>
);

Button.defaultProps = {
dataTest: 'TestDefaultDataValue',
disabled: false,
mode: 'primary',
onClick: null,
size: 'regular',
};

Button.propTypes = {
dataTest: PropTypes.string,
disabled: PropTypes.bool,
Expand Down
21 changes: 2 additions & 19 deletions src/components/ui/dropdown/dropdown-renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import Button from '../button';
*/
const DropdownRenderer = ({
children,
defaultText,
defaultText = 'Please select...',
disabled,
focusedOption,
handleRef,
Expand All @@ -25,7 +25,7 @@ const DropdownRenderer = ({
selectedOption,
showCancelApplyBtns,
title,
width,
width = 160,
placeholderText,
}) => {
const wrapperClasses = classnames('kedro', 'dropdown', {
Expand Down Expand Up @@ -169,23 +169,6 @@ const DropdownRenderer = ({
);
};

DropdownRenderer.defaultProps = {
children: null,
defaultText: 'Please select...',
disabled: false,
Huongg marked this conversation as resolved.
Show resolved Hide resolved
focusedOption: null,
handleRef: null,
haveSelectedValues: false,
onLabelClicked: null,
onOptionSelected: null,
onSelectChanged: null,
open: false,
selectedOption: null,
title: null,
width: 160,
placeholderText: null,
};

DropdownRenderer.propTypes = {
/**
* Child items. The nodes which React will pass down, defined inside the DropdownRenderer tag.
Expand Down
16 changes: 2 additions & 14 deletions src/components/ui/dropdown/dropdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import './dropdown.scss';
const Dropdown = (props) => {
const {
children,
defaultText,
defaultText = 'Please select...',
disabled,
haveSelectedValues,
onApplyAndClose,
Expand All @@ -20,7 +20,7 @@ const Dropdown = (props) => {
onClosed,
onOpened,
showCancelApplyBtns,
width,
width = 160,
placeholderText,
} = props;

Expand Down Expand Up @@ -333,18 +333,6 @@ const Dropdown = (props) => {
);
};

Dropdown.defaultProps = {
children: null,
defaultText: 'Please select...',
disabled: false,
haveSelectedValues: false,
onChanged: null,
onClosed: null,
onOpened: null,
width: 160,
placeholderText: null,
};

Dropdown.propTypes = {
/**
* Child items. The nodes which React will pass down, defined inside the DropdownRenderer tag
Expand Down
22 changes: 4 additions & 18 deletions src/components/ui/icon-button/icon-button.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,20 @@ const labelPositionTypes = ['right', 'left', 'bottom', 'top'];
* Icon button component
*/
const IconButton = ({
active,
active = false,
ariaLabel,
ariaLive,
children,
className,
container = 'li',
dataTest,
dataTest = 'TestDefaultDataValue',
dataHeapEvent,
disabled,
disabled = false,
icon,
labelText,
labelTextPosition = 'right',
onClick,
visible,
visible = true,
...rest
}) => {
const Icon = icon;
Expand Down Expand Up @@ -109,18 +109,4 @@ IconButton.propTypes = {
visible: PropTypes.bool,
};

IconButton.defaultProps = {
active: false,
ariaLabel: null,
ariaLive: null,
children: null,
dataTest: 'TestDefaultDataValue',
dataHeapEvent: null,
disabled: false,
icon: null,
labelText: null,
onClick: null,
visible: true,
};

export default IconButton;
13 changes: 2 additions & 11 deletions src/components/ui/menu-option/menu-option.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ import './menu-option.scss';
*/
const MenuOption = ({
className,
focused,
focused = false,
id,
onSelected,
primaryText,
selected,
selected = false,
value,
}) => {
const wrapperClasses = classnames('kedro', 'menu-option', className, {
Expand Down Expand Up @@ -61,15 +61,6 @@ const MenuOption = ({
);
};

MenuOption.defaultProps = {
className: null,
focused: false,
id: null,
onSelected: null,
selected: false,
value: null,
};

MenuOption.propTypes = {
/**
* Container class
Expand Down
5 changes: 0 additions & 5 deletions src/components/ui/search-bar/search-bar-renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,6 @@ const SearchBarRenderer = (props) => {
);
};

SearchBarRenderer.defaultProps = {
children: null,
onSubmit: null,
};

SearchBarRenderer.propTypes = {
/**
* Child component, usually search-bar-results
Expand Down
16 changes: 2 additions & 14 deletions src/components/ui/search-bar/search-bar.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ const SearchBar = ({
onClear,
onFocus,
onSubmit,
placeholder,
theme,
placeholder = 'Search Here...',
theme = 'dark',
value: inputValue,
}) => {
const [value, setValue] = useState(inputValue);
Expand Down Expand Up @@ -115,18 +115,6 @@ const SearchBar = ({
);
};

SearchBar.defaultProps = {
children: null,
placeholder: 'Search Here...',
onBlur: null,
onChange: null,
onClear: null,
onFocus: null,
onSubmit: null,
theme: 'dark',
value: '',
};

SearchBar.propTypes = {
/**
* Child component, usually search-bar-results
Expand Down
15 changes: 2 additions & 13 deletions src/components/ui/search-bar/search-input/search-input.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ import 'what-input';
import './search-input.scss';

const SearchInput = ({
disabled,
disabled = false,
label,
onBlur,
onChange,
onFocus,
placeholder,
theme,
theme = 'light',
value: inputValue,
}) => {
const [focused, setFocused] = useState(false);
Expand Down Expand Up @@ -92,17 +92,6 @@ const SearchInput = ({
);
};

SearchInput.defaultProps = {
disabled: false,
label: null,
onBlur: null,
onChange: null,
onFocus: null,
placeholder: null,
theme: 'light',
value: null,
};

SearchInput.propTypes = {
/**
* Whether the input should be editable or not.
Expand Down
27 changes: 8 additions & 19 deletions src/components/ui/tooltip/tooltip.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@ export const insertZeroWidthSpace = (text) =>
* @param {Boolean} visible Whether to show the tooltip
*/
const Tooltip = ({
arrowSize,
centerArrow,
chartSize,
noDelay,
style,
targetRect,
text,
visible,
arrowSize = 'regular',
centerArrow = false,
chartSize = {},
noDelay = false,
style = {},
targetRect = {},
text = '',
visible = false,
}) => {
let isTop = false,
isRight = false;
Expand Down Expand Up @@ -73,15 +73,4 @@ const Tooltip = ({
);
};

Tooltip.defaultProps = {
arrowSize: 'regular',
centerArrow: false,
chartSize: {},
noDelay: false,
style: {},
targetRect: {},
text: '',
visible: false,
};

export default Tooltip;
Loading