Skip to content

Commit bca3f28

Browse files
committed
Fix bug: calling mutation from unmounted component
1 parent c6cd296 commit bca3f28

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/components/Section.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class Section extends Component {
1414
return
1515
}
1616

17-
setTimeout(() => {
17+
this.timeoutID = setTimeout(() => {
1818
this.props.viewedSection({
1919
variables: { id }
2020
})
@@ -27,6 +27,10 @@ class Section extends Component {
2727
}
2828
}
2929

30+
componentWillUnmount() {
31+
clearTimeout(this.timeoutID)
32+
}
33+
3034
componentDidUpdate(prevProps) {
3135
const { id } = this.props.section
3236
const sectionChanged = get(prevProps, 'section.id') !== id

0 commit comments

Comments
 (0)