1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-10-22 11:22:43 +02:00

Fixed accounts auto scrolling (#17075)

* Fixed a bug

* Fixed additional bug
This commit is contained in:
Filip Sekulic 2023-02-28 15:23:24 +01:00 committed by GitHub
parent 5419f9414c
commit 426e3c37a4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,6 +1,7 @@
import React, { useLayoutEffect, useRef } from 'react';
import React, { memo, useLayoutEffect, useRef } from 'react';
import PropTypes from 'prop-types';
import classnames from 'classnames';
import { isEqual } from 'lodash';
import { useI18nContext } from '../../../hooks/useI18nContext';
import CheckBox, { CHECKED, INDETERMINATE, UNCHECKED } from '../check-box';
import Identicon from '../identicon';
@ -23,7 +24,7 @@ const AccountList = ({
const selectedAccountScrollRef = useRef(null);
useLayoutEffect(() => {
selectedAccountScrollRef.current?.scrollIntoView({ behavior: 'smooth' });
}, []);
}, [selectedAccounts]);
const Header = () => {
let checked;
@ -178,4 +179,6 @@ AccountList.propTypes = {
handleAccountClick: PropTypes.func.isRequired,
};
export default AccountList;
export default memo(AccountList, (prevProps, nextProps) => {
return isEqual(prevProps.selectedAccounts, nextProps.selectedAccounts);
});