From 1e5f8d0595fc069ac0ff2dde8808fef00731f159 Mon Sep 17 00:00:00 2001 From: Daniel Karbach Date: Mon, 2 Sep 2024 14:03:23 +0200 Subject: [PATCH] default props -> default arguments --- resources/js/components/chat-bot-logs/Item.js | 6 +--- resources/js/components/chat-bot-logs/List.js | 6 +--- resources/js/components/common/AspectBox.js | 7 +--- resources/js/components/common/Icon.js | 15 +++----- resources/js/components/common/LargeCheck.js | 21 ++++------- resources/js/components/common/Slider.js | 6 +--- .../js/components/common/ToggleSwitch.js | 35 ++++++------------- resources/js/components/protocol/Item.js | 6 +--- resources/js/components/protocol/List.js | 6 +--- .../js/components/rounds/SeedCodeInput.js | 21 ++++------- resources/js/components/tracker/Dungeons.js | 6 +--- 11 files changed, 33 insertions(+), 102 deletions(-) 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 @@ -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 = [] }) => {log ? log.map(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 }) =>
{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, }) => { const preset = ({ alt, className, name, size, title}) => { 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
{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 = {} }) =>
{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 = [] }) => {protocol ? protocol.map(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; -- 2.39.2