Kill off enzyme in preference of react testing library (#10255)

This commit is contained in:
Michael Telatynski 2023-03-06 15:17:46 +00:00 committed by GitHub
parent 394bffbae4
commit bda54a8b20
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 123 additions and 447 deletions

View file

@ -43,6 +43,8 @@ interface IState {
export default class MLocationBody extends React.Component<IBodyProps, IState> {
public static contextType = MatrixClientContext;
public context!: React.ContextType<typeof MatrixClientContext>;
private unmounted = false;
private mapId: string;
private reconnectedListener: ClientEventHandlerMap[ClientEvent.Sync];
@ -80,11 +82,15 @@ export default class MLocationBody extends React.Component<IBodyProps, IState> {
};
private onError = (error: Error): void => {
if (this.unmounted) return;
this.setState({ error });
// Unregister first in case we already had it registered
this.context.off(ClientEvent.Sync, this.reconnectedListener);
this.context.on(ClientEvent.Sync, this.reconnectedListener);
};
public componentWillUnmount(): void {
this.unmounted = true;
this.context.off(ClientEvent.Sync, this.reconnectedListener);
}