diff --git a/lib/Accordion/ExpandAllButton.js b/lib/Accordion/ExpandAllButton.js
index f680e64a9..86083273b 100644
--- a/lib/Accordion/ExpandAllButton.js
+++ b/lib/Accordion/ExpandAllButton.js
@@ -1,21 +1,19 @@
-import React from 'react';
+import React, { useMemo } from 'react';
import { flushSync } from 'react-dom';
import PropTypes from 'prop-types';
import { FormattedMessage } from 'react-intl';
-import isEqual from 'lodash/isEqual';
-import memoizeOne from 'memoize-one';
import expandAll from './expandCollapseAll';
import Button from '../Button';
import { withAccordionStatus } from './AccordionStatusContext';
// returns true if more keys in status are set to false than true;
-const majorityCollapsed = memoizeOne((status) => {
+const majorityCollapsed = (status) => {
const marjority = Object.keys(status).reduce(
(accum, id) => (status[id] ? accum + 1 : accum - 1),
0
);
return marjority < 0;
-}, isEqual);
+};
const propTypes = {
accordionStatus: PropTypes.object,
@@ -44,13 +42,12 @@ const ExpandAllButton = ({
onToggle,
setStatus,
}) => {
+ const func = useMemo(majorityCollapsed(accordionStatus), Object.values(accordionStatus));
const expandLabel = expandLabelProp ||
;
const collapseLabel = collapseLabelProp ||
;
- const func = majorityCollapsed(accordionStatus);
-
return (