Skip to content

Commit

Permalink
fix: fix console error on Picklist (nexxtway#2019)
Browse files Browse the repository at this point in the history
fix: nexxtway#2009

Co-authored-by: Jose Leandro Torres <jtorressicilia@gmail.com>
  • Loading branch information
2 people authored and jpetaux committed Jun 4, 2021
1 parent b84767a commit c3a5633
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/components/InternalDropdown/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,13 @@ const InternalDropdown = forwardRef((props, reference) => {
contains: element => containerRef.current.contains(element),
}));

const isComponentMounted = useRef(true);
useEffect(() => {
return () => {
isComponentMounted.current = false;
};
}, []);

const updateScrollingArrows = () => {
const menu = menuRef.current;
setShowScrollUpArrow(menu.scrollTop > 0);
Expand All @@ -96,6 +103,7 @@ const InternalDropdown = forwardRef((props, reference) => {
}, []);

const registerChild = useCallback((childRef, childProps) => {
if (!isComponentMounted.current) return;
if (isChildRegistered(childProps.name, activeChildren.current)) return;
if (!firstChild.current) {
firstChild.current = childProps;
Expand All @@ -114,6 +122,7 @@ const InternalDropdown = forwardRef((props, reference) => {
}, []);

const unregisterChild = useCallback((childRef, name) => {
if (!isComponentMounted.current) return;
if (!isChildRegistered(name, activeChildren.current)) return;
const newChildren = activeChildren.current.filter(child => child.name !== name);
activeChildren.current = newChildren;
Expand Down

0 comments on commit c3a5633

Please sign in to comment.