Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Async dispose in Component unmount #636

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,13 @@ export class CollectionColorField extends React.Component<ICollectionColorFieldP
public UNSAFE_componentWillMount(): void {
this.valueChange(this.props.field, this.props.item[this.props.field.id]).then(() => { /* no-op; */ }).catch(() => { /* no-op; */ });
}

/**
* componentWillUnmount lifecycle hook
*/
public componentWillUnmount(): void {
this.async.dispose();
}

private _onCalloutDismiss = (): void => {
this.setState({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,13 @@ export class CollectionNumberField extends React.Component<
}
}

/**
* componentWillUnmount lifecycle hook
*/
public componentWillUnmount(): void {
this.async.dispose();
}

/**
* Value change event handler
*
Expand Down
7 changes: 7 additions & 0 deletions src/propertyFields/number/PropertyFieldNumberHost.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,13 @@ export default class PropertyFieldNumberHost extends React.Component<IPropertyFi
}
}

/**
* componentWillUnmount lifecycle hook
*/
public componentWillUnmount(): void {
this._async.dispose();
}

/**
* Validate if field value is a number
* @param value
Expand Down
7 changes: 7 additions & 0 deletions src/propertyFields/sitePicker/PropertyFieldSitePickerHost.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,13 @@ export default class PropertyFieldSitePickerHost extends React.Component<IProper
this.setState({ selectedSites });
}

/**
* componentWillUnmount lifecycle hook
*/
public componentWillUnmount(): void {
this.async.dispose();
}

public render(): JSX.Element {
const { isLoading, siteSearchResults, selectedSites } = this.state;

Expand Down
7 changes: 7 additions & 0 deletions src/propertyFields/teamPicker/PropertyFieldTeamPickerHost.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,13 @@ export default class PropertyFieldTeamPickerHost extends React.Component<IProper
this.setState({ selectedTeams });
}

/**
* componentWillUnmount lifecycle hook
*/
public componentWillUnmount(): void {
this.async.dispose();
}

public render(): JSX.Element {
const { isLoading, teamSearchResults, selectedTeams } = this.state;

Expand Down