From: Daniel Karbach <daniel.karbach@localhorst.tv>
Date: Mon, 2 Sep 2024 12:03:23 +0000 (+0200)
Subject: default props -> default arguments
X-Git-Url: https://git.localhorst.tv/?a=commitdiff_plain;h=1e5f8d0595fc069ac0ff2dde8808fef00731f159;p=alttp.git

default props -> default arguments
---

diff --git a/resources/js/components/chat-bot-logs/Item.js b/resources/js/components/chat-bot-logs/Item.js
index f50d078..4c55c59 100644
--- a/resources/js/components/chat-bot-logs/Item.js
+++ b/resources/js/components/chat-bot-logs/Item.js
@@ -39,7 +39,7 @@ const getEntryInfo = (entry, t) => {
 	return getEntryDate(entry);
 };
 
-const Item = ({ entry }) => {
+const Item = ({ entry = {} }) => {
 	const { t } = useTranslation();
 
 	return <ListGroup.Item>
@@ -72,8 +72,4 @@ Item.propTypes = {
 	}),
 };
 
-Item.defaultProps = {
-	entry: {},
-};
-
 export default Item;
diff --git a/resources/js/components/chat-bot-logs/List.js b/resources/js/components/chat-bot-logs/List.js
index 9838b8e..0411299 100644
--- a/resources/js/components/chat-bot-logs/List.js
+++ b/resources/js/components/chat-bot-logs/List.js
@@ -4,7 +4,7 @@ import { ListGroup } from 'react-bootstrap';
 
 import Item from './Item';
 
-const List = ({ log }) =>
+const List = ({ log = [] }) =>
 	<ListGroup variant="flush">
 		{log ? log.map(entry =>
 			<Item key={entry.id} entry={entry} />
@@ -16,8 +16,4 @@ List.propTypes = {
 	})),
 };
 
-List.defaultProps = {
-	log: [],
-};
-
 export default List;
diff --git a/resources/js/components/common/AspectBox.js b/resources/js/components/common/AspectBox.js
index 52709c1..ead009d 100644
--- a/resources/js/components/common/AspectBox.js
+++ b/resources/js/components/common/AspectBox.js
@@ -1,7 +1,7 @@
 import PropTypes from 'prop-types';
 import React from 'react';
 
-const AspectBox = ({ children, ratio }) =>
+const AspectBox = ({ children = null, ratio = 1 }) =>
 	<div className="aspect-box-container" style={{ paddingTop: `${1 / ratio * 100}%`}}>
 		<div className="aspect-box-content">
 			{children}
@@ -13,9 +13,4 @@ AspectBox.propTypes = {
 	ratio: PropTypes.number,
 };
 
-AspectBox.defaultProps = {
-	children: null,
-	ratio: 1,
-};
-
 export default AspectBox;
diff --git a/resources/js/components/common/Icon.js b/resources/js/components/common/Icon.js
index f3caeb3..56d5862 100644
--- a/resources/js/components/common/Icon.js
+++ b/resources/js/components/common/Icon.js
@@ -12,11 +12,11 @@ library.add(fab);
 library.add(fas);
 
 const Icon = ({
-	alt,
-	className,
+	alt = null,
+	className = '',
 	name,
-	size,
-	title,
+	size = null,
+	title = null,
 }) =>
 	<FontAwesomeIcon
 		icon={name}
@@ -38,13 +38,6 @@ Icon.propTypes = {
 	title: PropTypes.string,
 };
 
-Icon.defaultProps = {
-	alt: null,
-	className: '',
-	size: null,
-	title: null,
-};
-
 const makePreset = (presetDisplayName, presetName) => {
 	const preset = ({ alt, className, name, size, title}) => <Icon
 		alt={alt || i18n.t(`icon.${presetDisplayName}`)}
diff --git a/resources/js/components/common/LargeCheck.js b/resources/js/components/common/LargeCheck.js
index e159b45..9586280 100644
--- a/resources/js/components/common/LargeCheck.js
+++ b/resources/js/components/common/LargeCheck.js
@@ -4,12 +4,12 @@ import React from 'react';
 import Icon from './Icon';
 
 const LargeCheck = ({
-	className,
-	id,
-	name,
-	onBlur,
-	onChange,
-	value,
+	className = '',
+	id = '',
+	name = '',
+	onBlur = null,
+	onChange = null,
+	value = false,
 }) => {
 	let clsn = className ? `${className} custom-check` : 'custom-check';
 	if (value) {
@@ -42,13 +42,4 @@ LargeCheck.propTypes = {
 	value: PropTypes.bool,
 };
 
-LargeCheck.defaultProps = {
-	className: '',
-	id: '',
-	name: '',
-	onBlur: null,
-	onChange: null,
-	value: false,
-};
-
 export default LargeCheck;
diff --git a/resources/js/components/common/Slider.js b/resources/js/components/common/Slider.js
index 634c15c..587fc7f 100644
--- a/resources/js/components/common/Slider.js
+++ b/resources/js/components/common/Slider.js
@@ -1,7 +1,7 @@
 import PropTypes from 'prop-types';
 import React from 'react';
 
-const Slider = ({ children, duration, vertical }) => {
+const Slider = ({ children = null, duration = 2500, vertical = false }) => {
 	const [index, setIndex] = React.useState(0);
 
 	React.useEffect(() => {
@@ -28,10 +28,6 @@ Slider.propTypes = {
 	vertical: PropTypes.bool,
 };
 
-Slider.defaultProps = {
-	duration: 2500,
-};
-
 const Slide = ({ children }) => {
 	return <div className="slider-slide">
 		{children}
diff --git a/resources/js/components/common/ToggleSwitch.js b/resources/js/components/common/ToggleSwitch.js
index db07619..98d3d06 100644
--- a/resources/js/components/common/ToggleSwitch.js
+++ b/resources/js/components/common/ToggleSwitch.js
@@ -4,16 +4,16 @@ import React from 'react';
 import Icon from './Icon';
 
 const ToggleSwitch = ({
-	isInvalid,
-	isValid,
-	name,
-	offLabel,
-	onBlur,
-	onChange,
-	onLabel,
-	readonly,
-	title,
-	value,
+	isInvalid = false,
+	isValid = false,
+	name = '',
+	offLabel = '',
+	onBlur = null,
+	onChange = null,
+	onLabel = null,
+	readonly = false,
+	title = null,
+	value = false,
 }) => {
 	const toggle = () => {
 		if (readonly) return;
@@ -61,7 +61,6 @@ const ToggleSwitch = ({
 };
 
 ToggleSwitch.propTypes = {
-	id: PropTypes.string,
 	isInvalid: PropTypes.bool,
 	isValid: PropTypes.bool,
 	name: PropTypes.string,
@@ -74,18 +73,4 @@ ToggleSwitch.propTypes = {
 	value: PropTypes.bool,
 };
 
-ToggleSwitch.defaultProps = {
-	id: '',
-	isInvalid: false,
-	isValid: false,
-	name: '',
-	offLabel: '',
-	onBlur: null,
-	onChange: null,
-	onLabel: '',
-	readonly: false,
-	title: null,
-	value: false,
-};
-
 export default ToggleSwitch;
diff --git a/resources/js/components/protocol/Item.js b/resources/js/components/protocol/Item.js
index 7dba2a3..7c3da40 100644
--- a/resources/js/components/protocol/Item.js
+++ b/resources/js/components/protocol/Item.js
@@ -115,7 +115,7 @@ const getEntryIcon = entry => {
 	}
 };
 
-const Item = ({ entry }) =>
+const Item = ({ entry = {} }) =>
 	<ListGroup.Item className="d-flex align-items-center">
 		<div className="pe-3 text-muted">
 			{getEntryIcon(entry)}
@@ -139,8 +139,4 @@ Item.propTypes = {
 	}),
 };
 
-Item.defaultProps = {
-	entry: {},
-};
-
 export default withTranslation()(Item);
diff --git a/resources/js/components/protocol/List.js b/resources/js/components/protocol/List.js
index 55e0ecb..9179ad5 100644
--- a/resources/js/components/protocol/List.js
+++ b/resources/js/components/protocol/List.js
@@ -4,7 +4,7 @@ import { ListGroup } from 'react-bootstrap';
 
 import Item from './Item';
 
-const List = ({ protocol }) =>
+const List = ({ protocol = [] }) =>
 	<ListGroup variant="flush">
 		{protocol ? protocol.map(entry =>
 			<Item key={entry.id} entry={entry} />
@@ -16,8 +16,4 @@ List.propTypes = {
 	})),
 };
 
-List.defaultProps = {
-	protocol: [],
-};
-
 export default List;
diff --git a/resources/js/components/rounds/SeedCodeInput.js b/resources/js/components/rounds/SeedCodeInput.js
index 2431ca3..958c927 100644
--- a/resources/js/components/rounds/SeedCodeInput.js
+++ b/resources/js/components/rounds/SeedCodeInput.js
@@ -76,12 +76,12 @@ const SMR_CODES = [
 ];
 
 const SeedCodeInput = ({
-	className,
-	game,
-	name,
-	onBlur,
-	onChange,
-	value,
+	className = '',
+	game = '',
+	name = '',
+	onBlur = null,
+	onChange = null,
+	value = [],
 }) => {
 	if (game === 'alttpr') {
 		const code_trans = ALTTPR_CODES
@@ -150,13 +150,4 @@ SeedCodeInput.propTypes = {
 	value: PropTypes.arrayOf(PropTypes.string),
 };
 
-SeedCodeInput.defaultProps = {
-	className: '',
-	game: '',
-	name: '',
-	onBlur: null,
-	onChange: null,
-	value: [],
-};
-
 export default withTranslation()(SeedCodeInput);
diff --git a/resources/js/components/tracker/Dungeons.js b/resources/js/components/tracker/Dungeons.js
index 8a7e4d0..758935c 100644
--- a/resources/js/components/tracker/Dungeons.js
+++ b/resources/js/components/tracker/Dungeons.js
@@ -12,7 +12,7 @@ import {
 } from '../../helpers/tracker';
 import { useTracker } from '../../hooks/tracker';
 
-const Dungeons = ({ columns }) => {
+const Dungeons = ({ columns = 4 }) => {
 	const { config, dungeons, state } = useTracker();
 
 	const layout = React.useMemo(() => {
@@ -201,8 +201,4 @@ Dungeons.propTypes = {
 	columns: PropTypes.number,
 };
 
-Dungeons.defaultProps = {
-	columns: 4,
-};
-
 export default Dungeons;