Skip to content

Commit

Permalink
fix(UISrefActive): Avoid reusing the same array reference during setS…
Browse files Browse the repository at this point in the history
…tate() call

The component wasn't getting rendered after calling setUiSrefs() because
the same array reference was passed in due to the use of removeFrom()
  • Loading branch information
christopherthielen authored and mergify[bot] committed Jan 6, 2020
1 parent 97289e7 commit b9064cd
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions src/components/UISrefActive.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
/** */

import * as React from 'react';
import { removeFrom } from '@uirouter/core';
import { useState, useCallback, useContext, useMemo, cloneElement } from 'react';
import * as _classNames from 'classnames';

Expand Down Expand Up @@ -89,7 +88,7 @@ export function UISrefActive({ children, className, class: classToApply, exact }
setUiSrefs(uiSrefs => uiSrefs.concat(addedUiSref));
return () => {
parentDeregister();
setUiSrefs(uiSrefs => removeFrom(uiSrefs, addedUiSref));
setUiSrefs(uiSrefs => uiSrefs.filter(x => x !== addedUiSref));
};
},
[parentAddStateInfo]
Expand Down

0 comments on commit b9064cd

Please sign in to comment.