Skip to content

Commit

Permalink
fix(select): defensive foundation check before unmounting - also incl…
Browse files Browse the repository at this point in the history
…udes radio, checkbox, text-field (#512)
  • Loading branch information
hvolschenk authored and Matt Goo committed Dec 12, 2018
1 parent 179b865 commit 2ee4c80
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 6 deletions.
4 changes: 3 additions & 1 deletion packages/checkbox/index.js
Expand Up @@ -69,7 +69,9 @@ export class Checkbox extends Component {
}

componentWillUnmount() {
this.foundation_.destroy();
if (this.foundation_) {
this.foundation_.destroy();
}
}

init = (el) => {
Expand Down
4 changes: 3 additions & 1 deletion packages/radio/index.js
Expand Up @@ -59,7 +59,9 @@ class Radio extends React.Component {
}

componentWillUnmount() {
this.foundation_.destroy();
if (this.foundation_) {
this.foundation_.destroy();
}
}

componentDidUpdate(prevProps, prevState) {
Expand Down
4 changes: 3 additions & 1 deletion packages/select/index.js
Expand Up @@ -72,7 +72,9 @@ export default class Select extends React.Component {
}

componentWillUnmount() {
this.foundation_.destroy();
if (this.foundation_) {
this.foundation_.destroy();
}
}

onChange = (evt) => {
Expand Down
4 changes: 3 additions & 1 deletion packages/text-field/helper-text/index.js
Expand Up @@ -66,7 +66,9 @@ export default class HelperText extends React.Component {
}

componentWillUnmount() {
this.foundation_.destroy();
if (this.foundation_) {
this.foundation_.destroy();
}
}

get classes() {
Expand Down
4 changes: 3 additions & 1 deletion packages/text-field/icon/index.js
Expand Up @@ -57,7 +57,9 @@ export default class Icon extends React.Component {
}

componentWillUnmount() {
this.foundation_.destroy();
if (this.foundation_) {
this.foundation_.destroy();
}
}

get adapter() {
Expand Down
4 changes: 3 additions & 1 deletion packages/text-field/index.js
Expand Up @@ -79,7 +79,9 @@ class TextField extends React.Component {
}

componentWillUnmount() {
this.state.foundation.destroy();
if (this.state.foundation) {
this.state.foundation.destroy();
}
}

/**
Expand Down

0 comments on commit 2ee4c80

Please sign in to comment.