Skip to content

Commit 0740825

Browse files
committed
fix(UISref): Add call to deregister function when component is unmounted
1 parent ca2605d commit 0740825

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/components/UISref.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ export interface IProps {
1313
className?: string;
1414
}
1515
export class UISref extends Component<IProps,any> {
16+
// deregister function for parent UISrefActive
17+
deregister: Function;
1618
static propTypes = {
1719
children: PropTypes.element.isRequired,
1820
to: PropTypes.string.isRequired,
@@ -28,7 +30,13 @@ export class UISref extends Component<IProps,any> {
2830

2931
componentWillMount () {
3032
const addStateInfo = this.context['parentUiSrefActiveAddStateInfo'];
31-
typeof addStateInfo === 'function' && addStateInfo(this.props.to, this.props.params);
33+
this.deregister = typeof addStateInfo === 'function'
34+
? addStateInfo(this.props.to, this.props.params)
35+
: () => {};
36+
}
37+
38+
componentWillUnmount () {
39+
this.deregister();
3240
}
3341

3442
getOptions = () => {

0 commit comments

Comments
 (0)