Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const LocalizedTextInput = props => {
const defaultExpansionState =
props.hideLanguageExpansionControls ||
props.defaultExpandLanguages || // default to `false`, because useToggleState defaults to `true`
false;
const [areLanguagesExpanded, toggleLanguages] = useToggleState(
defaultExpansionState
);
const languages = sortLanguages(
props.selectedLanguage,
Object.keys(props.value)
);
const id = useFieldId(props.id, sequentialId);
const hasErrorInRemainingLanguages =
props.hasError ||
getHasErrorOnRemainingLanguages(props.errors, props.selectedLanguage);
if (hasErrorInRemainingLanguages) {
// this update within render replaces the old `getDerivedStateFromProps` functionality
// https://reactjs.org/docs/hooks-faq.html#how-do-i-implement-getderivedstatefromprops
if (hasErrorInRemainingLanguages !== areLanguagesExpanded) {
toggleLanguages();
}
}
return (
const LocalizedMoneyInput = props => {
const intl = useIntl();
const defaultExpansionState =
props.hideCurrencyExpansionControls ||
props.defaultExpandCurrencies ||
// default to `false`, because useToggleState defaults to `true`
false;
const [areCurrenciesExpanded, toggleCurrencies] = useToggleState(
defaultExpansionState
);
const id = useFieldId(props.id, sequentialId);
const hasErrorInRemainingCurrencies =
props.hasError ||
getHasErrorOnRemainingLanguages(props.errors, props.selectedCurrency);
const hasWarningInRemainingCurrencies =
props.hasWarning ||
getHasWarningOnRemainingLanguages(props.warnings, props.selectedCurrency);
if (hasErrorInRemainingCurrencies || hasWarningInRemainingCurrencies) {
// this update within render replaces the old `getDerivedStateFromProps` functionality
// https://reactjs.org/docs/hooks-faq.html#how-do-i-implement-getderivedstatefromprops
if (!areCurrenciesExpanded) {
toggleCurrencies();
}
}
const PasswordField = props => {
const intl = useIntl();
const [isPasswordVisible, togglePasswordVisibility] = useToggleState(false);
const id = useFieldId(props.id, sequentialId);
const hasError = props.touched && hasErrors(props.errors);
return (