Fix default props.

new-frontend
Icedream 2023-01-09 02:31:33 +01:00
parent dd773852f9
commit cad0003676
Signed by: icedream
GPG Key ID: 468BBEEBB9EC6AEA
5 changed files with 43 additions and 16 deletions

View File

@ -25,21 +25,21 @@ import { Overlay, Tooltip } from 'react-bootstrap';
import type { IconProp } from '@fortawesome/fontawesome-svg-core';
import { FormattedMessage } from './localization';
const CopyField = ({
function CopyField({
children,
copyIcon = 'copy',
icon = null,
copyIcon,
icon,
}: {
children: string,
copyIcon?: IconProp,
icon?: IconProp,
}) => {
}) {
const [show, setShow] = useState(false);
const target = useRef(null);
const textbox = useRef(null);
let timer: NodeJS.Timeout = null;
function doCopy() {
const doCopy = () => {
if (timer !== null) {
clearTimeout(timer);
}
@ -52,7 +52,7 @@ const CopyField = ({
setShow(false);
}, 3000);
return false;
}
};
return (
<InputGroup>
@ -83,6 +83,11 @@ const CopyField = ({
</Button>
</InputGroup>
);
}
CopyField.defaultProps = {
copyIcon: 'copy',
icon: null,
};
export default CopyField;

View File

@ -25,10 +25,10 @@ import {
import { FormattedMessage } from './localization';
export default function DarkToggler({
isDarkEnabled = false,
onChangeDarkMode = null,
disabled = false,
showLoading = false,
isDarkEnabled,
onChangeDarkMode,
disabled,
showLoading,
}: {
isDarkEnabled?: boolean,
onChangeDarkMode?: (value: boolean) => void,
@ -55,3 +55,10 @@ export default function DarkToggler({
</Button>
);
}
DarkToggler.defaultProps = {
isDarkEnabled: false,
onChangeDarkMode: null,
disabled: false,
showLoading: false,
};

View File

@ -23,7 +23,7 @@ import { getDownloadURL } from 'util/api';
import { FormattedMessage } from './localization';
export default function DownloadButton({
icon = 'download',
icon,
id,
fileName,
}: {
@ -42,3 +42,7 @@ export default function DownloadButton({
</Button>
);
}
DownloadButton.defaultProps = {
icon: 'download',
};

View File

@ -21,7 +21,7 @@ import React from 'react';
export default function Filter<T, U extends React.ReactNode>({
items,
query = '',
isCaseSensitive = false,
isCaseSensitive,
keys,
output,
}: {
@ -50,3 +50,7 @@ export default function Filter<T, U extends React.ReactNode>({
</>
);
}
Filter.defaultProps = {
isCaseSensitive: false,
};

View File

@ -24,10 +24,10 @@ import { FormattedMessage } from './localization';
import { availableLocales, defaultLocale, localeDescriptions } from '../util/localization';
export default function LocaleSwitcher({
locale = defaultLocale,
onChangeLocale = null,
disabled = false,
showLoading = false,
locale,
onChangeLocale,
disabled,
showLoading,
}: {
locale?: string,
onChangeLocale?: (value: string) => void,
@ -76,3 +76,10 @@ export default function LocaleSwitcher({
</DropdownButton>
);
}
LocaleSwitcher.defaultProps = {
locale: defaultLocale,
onChangeLocale: null,
disabled: false,
showLoading: false,
};