diff --git a/src/components/views/rooms/EditMessageComposer.tsx b/src/components/views/rooms/EditMessageComposer.tsx index 9c0bea4e60..4e51a0105b 100644 --- a/src/components/views/rooms/EditMessageComposer.tsx +++ b/src/components/views/rooms/EditMessageComposer.tsx @@ -121,14 +121,15 @@ interface IState { @replaceableComponent("views.rooms.EditMessageComposer") export default class EditMessageComposer extends React.Component { static contextType = MatrixClientContext; - context: React.ContextType; + context!: React.ContextType; private readonly editorRef = createRef(); private readonly dispatcherRef: string; private model: EditorModel = null; constructor(props: IProps, context: React.ContextType) { - super(props, context); + super(props); + this.context = context; // otherwise React will only set it prior to render due to type def above this.state = { saveDisabled: true, diff --git a/src/components/views/rooms/SendMessageComposer.tsx b/src/components/views/rooms/SendMessageComposer.tsx index a934216884..f088ec0c8e 100644 --- a/src/components/views/rooms/SendMessageComposer.tsx +++ b/src/components/views/rooms/SendMessageComposer.tsx @@ -136,7 +136,7 @@ interface IProps { @replaceableComponent("views.rooms.SendMessageComposer") export default class SendMessageComposer extends React.Component { static contextType = MatrixClientContext; - context: React.ContextType; + context!: React.ContextType; private readonly prepareToEncrypt?: RateLimitedFunc; private readonly editorRef = createRef(); @@ -146,8 +146,9 @@ export default class SendMessageComposer extends React.Component { private sendHistoryManager: SendHistoryManager; constructor(props: IProps, context: React.ContextType) { - super(props, context); - if (context.isCryptoEnabled() && context.isRoomEncrypted(this.props.room.roomId)) { + super(props); + this.context = context; // otherwise React will only set it prior to render due to type def above + if (this.context.isCryptoEnabled() && this.context.isRoomEncrypted(this.props.room.roomId)) { this.prepareToEncrypt = new RateLimitedFunc(() => { this.context.prepareToEncrypt(this.props.room); }, 60000);