Skip to content

Commit

Permalink
fix(hierarchylist): need to useDeepCompareEffect to stop infinite loop
Browse files Browse the repository at this point in the history
  • Loading branch information
scottdickerson committed Nov 12, 2020
1 parent 0dceb12 commit aa16110
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/components/List/HierarchyList/HierarchyList.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,8 @@ const HierarchyList = ({
cancelMoveClicked();
};

useEffect(
useDeepCompareEffect(
// have to use deep compare to accurately compare items
() => {
// Expand the parent elements of the defaultSelectedId
if (defaultSelectedId) {
Expand Down
4 changes: 2 additions & 2 deletions src/components/List/List.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { forwardRef } from 'react';
import React, { forwardRef, useMemo } from 'react';
import PropTypes from 'prop-types';
import classnames from 'classnames';
import { DragDropContext } from 'react-dnd';
Expand Down Expand Up @@ -144,7 +144,7 @@ const List = forwardRef((props, ref) => {
itemWillMove,
emptyState,
} = props;
const mergedI18n = { ...defaultProps.i18n, i18n };
const mergedI18n = useMemo(() => ({ ...defaultProps.i18n, i18n }), [i18n]);
const selectedItemRef = ref;
const ListHeader = overrides?.header?.component || DefaultListHeader;
const renderItemAndChildren = (item, index, parentId, level) => {
Expand Down

0 comments on commit aa16110

Please sign in to comment.