diff --git a/ui/app/components/app/account-list-item/account-list-item.js b/ui/app/components/app/account-list-item/account-list-item.js index 5823e2923..362c740d0 100644 --- a/ui/app/components/app/account-list-item/account-list-item.js +++ b/ui/app/components/app/account-list-item/account-list-item.js @@ -16,7 +16,7 @@ export default function AccountListItem({ return (
handleClick && handleClick({ name, address, balance })} + onClick={() => handleClick?.({ name, address, balance })} >
{ 'confirm-detail-row__header-text', headerTextClassName, )} - onClick={() => onHeaderClick && onHeaderClick()} + onClick={() => onHeaderClick?.()} > {headerText}
diff --git a/ui/app/components/app/modals/account-details-modal/account-details-modal.component.js b/ui/app/components/app/modals/account-details-modal/account-details-modal.component.js index 71350b9a3..e3b874d4c 100644 --- a/ui/app/components/app/modals/account-details-modal/account-details-modal.component.js +++ b/ui/app/components/app/modals/account-details-modal/account-details-modal.component.js @@ -37,7 +37,7 @@ export default class AccountDetailsModal extends Component { let exportPrivateKeyFeatureEnabled = true // This feature is disabled for hardware wallets - if (keyring && keyring.type.search('Hardware') !== -1) { + if (keyring && keyring?.type?.search('Hardware') !== -1) { exportPrivateKeyFeatureEnabled = false } diff --git a/ui/app/components/app/sidebars/sidebar.component.js b/ui/app/components/app/sidebars/sidebar.component.js index 12dee2c05..37c1abcd9 100644 --- a/ui/app/components/app/sidebars/sidebar.component.js +++ b/ui/app/components/app/sidebars/sidebar.component.js @@ -21,7 +21,7 @@ export default class Sidebar extends Component {
{ - onOverlayClose && onOverlayClose() + onOverlayClose?.() this.props.hideSidebar() }} /> diff --git a/ui/app/components/ui/button-group/button-group.component.js b/ui/app/components/ui/button-group/button-group.component.js index d3082ae61..aeb9b37d3 100644 --- a/ui/app/components/ui/button-group/button-group.component.js +++ b/ui/app/components/ui/button-group/button-group.component.js @@ -63,7 +63,7 @@ export default class ButtonGroup extends PureComponent { )} onClick={() => { this.handleButtonClick(index) - child.props.onClick && child.props.onClick() + child.props.onClick?.() }} disabled={disabled || child.props.disabled} key={index} diff --git a/ui/app/ducks/confirm-transaction/confirm-transaction.duck.test.js b/ui/app/ducks/confirm-transaction/confirm-transaction.duck.test.js index 441fb8563..d1d427502 100644 --- a/ui/app/ducks/confirm-transaction/confirm-transaction.duck.test.js +++ b/ui/app/ducks/confirm-transaction/confirm-transaction.duck.test.js @@ -465,7 +465,7 @@ describe('Confirm Transaction Duck', function () { .stub() .callsFake((address) => Promise.resolve( - address && address.match(/isContract/u) ? 'not-0x' : '0x', + address?.match(/isContract/u) ? 'not-0x' : '0x', ), ), } diff --git a/ui/app/helpers/utils/token-util.js b/ui/app/helpers/utils/token-util.js index 477238cdf..804b58b90 100644 --- a/ui/app/helpers/utils/token-util.js +++ b/ui/app/helpers/utils/token-util.js @@ -36,7 +36,7 @@ async function getDecimalsFromContract(tokenAddress) { try { const result = await token.decimals() const decimalsBN = result[0] - return decimalsBN && decimalsBN.toString() + return decimalsBN?.toString() } catch (error) { log.warn( `decimals() call for token at address ${tokenAddress} resulted in error:`, diff --git a/ui/app/pages/confirm-send-ether/confirm-send-ether.container.js b/ui/app/pages/confirm-send-ether/confirm-send-ether.container.js index 336cf4a4a..8eca1803f 100644 --- a/ui/app/pages/confirm-send-ether/confirm-send-ether.container.js +++ b/ui/app/pages/confirm-send-ether/confirm-send-ether.container.js @@ -30,7 +30,7 @@ const mapDispatchToProps = (dispatch) => { to, amount, errors: { to: null, amount: null }, - editingTransactionId: id && id.toString(), + editingTransactionId: id?.toString(), }), ) diff --git a/ui/app/pages/confirm-send-token/confirm-send-token.container.js b/ui/app/pages/confirm-send-token/confirm-send-token.container.js index c02f43adb..04bb1f7b2 100644 --- a/ui/app/pages/confirm-send-token/confirm-send-token.container.js +++ b/ui/app/pages/confirm-send-token/confirm-send-token.container.js @@ -44,7 +44,7 @@ const mapDispatchToProps = (dispatch) => { to, amount: tokenAmountInHex, errors: { to: null, amount: null }, - editingTransactionId: id && id.toString(), + editingTransactionId: id?.toString(), token: { ...tokenProps, address: tokenAddress, diff --git a/ui/app/pages/confirm-token-transaction-base/confirm-token-transaction-base.container.js b/ui/app/pages/confirm-token-transaction-base/confirm-token-transaction-base.container.js index 8be624aa2..ca67434ae 100644 --- a/ui/app/pages/confirm-token-transaction-base/confirm-token-transaction-base.container.js +++ b/ui/app/pages/confirm-token-transaction-base/confirm-token-transaction-base.container.js @@ -42,7 +42,7 @@ const mapStateToProps = (state, ownProps) => { ) const tokens = getTokens(state) const currentToken = - tokens && tokens.find(({ address }) => tokenAddress === address) + tokens?.find(({ address }) => tokenAddress === address) const { decimals, symbol: tokenSymbol } = currentToken || {} const tokenData = getTokenData(data) diff --git a/ui/app/pages/confirm-transaction-switch/confirm-transaction-switch.container.js b/ui/app/pages/confirm-transaction-switch/confirm-transaction-switch.container.js index a8266c417..59d3f9555 100644 --- a/ui/app/pages/confirm-transaction-switch/confirm-transaction-switch.container.js +++ b/ui/app/pages/confirm-transaction-switch/confirm-transaction-switch.container.js @@ -9,7 +9,7 @@ const mapStateToProps = (state, ownProps) => { const { match: { params = {}, url }, } = ownProps - const urlId = url && url.match(/\d+/u) && url.match(/\d+/u)[0] + const urlId = url?.match(/\d+/u) && url?.match(/\d+/u)[0] const { id: paramsId } = params const transactionId = paramsId || urlId diff --git a/ui/app/pages/send/send.component.js b/ui/app/pages/send/send.component.js index e35d39561..af6a7434c 100644 --- a/ui/app/pages/send/send.component.js +++ b/ui/app/pages/send/send.component.js @@ -160,7 +160,7 @@ export default class SendTransactionScreen extends Component { if (qrCodeData) { if (qrCodeData.type === 'address') { scannedAddress = qrCodeData.values.address.toLowerCase() - const currentAddress = prevTo && prevTo.toLowerCase() + const currentAddress = prevTo?.toLowerCase() if (currentAddress !== scannedAddress) { updateSendTo(scannedAddress) updateGas = true diff --git a/ui/app/pages/settings/networks-tab/network-form/network-form.component.js b/ui/app/pages/settings/networks-tab/network-form/network-form.component.js index 83d506420..e7acdbaa5 100644 --- a/ui/app/pages/settings/networks-tab/network-form/network-form.component.js +++ b/ui/app/pages/settings/networks-tab/network-form/network-form.component.js @@ -260,7 +260,7 @@ export default class NetworkForm extends PureComponent { setStateWithValue = (stateKey, validator) => { return (e) => { - validator && validator(e.target.value, stateKey) + validator?.(e.target.value, stateKey) this.setState({ [stateKey]: e.target.value }) } } diff --git a/ui/app/pages/swaps/dropdown-search-list/dropdown-search-list.js b/ui/app/pages/swaps/dropdown-search-list/dropdown-search-list.js index 70de26654..b6d85400d 100644 --- a/ui/app/pages/swaps/dropdown-search-list/dropdown-search-list.js +++ b/ui/app/pages/swaps/dropdown-search-list/dropdown-search-list.js @@ -37,12 +37,12 @@ export default function DropdownSearchList({ const [selectedItem, setSelectedItem] = useState(startingItem) const close = useCallback(() => { setIsOpen(false) - onClose && onClose() + onClose?.() }, [onClose]) const onClickItem = useCallback( (item) => { - onSelect && onSelect(item) + onSelect?.(item) setSelectedItem(item) close() }, @@ -52,7 +52,7 @@ export default function DropdownSearchList({ const onClickSelector = useCallback(() => { if (!isOpen) { setIsOpen(true) - onOpen && onOpen() + onOpen?.() } }, [isOpen, onOpen]) @@ -165,7 +165,7 @@ export default function DropdownSearchList({ onClick={(event) => { event.stopPropagation() setIsOpen(false) - onClose && onClose() + onClose?.() }} /> diff --git a/ui/app/pages/swaps/searchable-item-list/item-list/item-list.component.js b/ui/app/pages/swaps/searchable-item-list/item-list/item-list.component.js index fe2062d48..4ef6aeeb5 100644 --- a/ui/app/pages/swaps/searchable-item-list/item-list/item-list.component.js +++ b/ui/app/pages/swaps/searchable-item-list/item-list/item-list.component.js @@ -31,11 +31,11 @@ export default function ItemList({ ref={containerRef} > {results.slice(0, maxListItems).map((result, i) => { - if (hideItemIf && hideItemIf(result)) { + if (hideItemIf?.(result)) { return null } - const onClick = () => onClickItem && onClickItem(result) + const onClick = () => onClickItem?.(result) const { iconUrl, identiconAddress,