From ddf558b3ed5042f2c953ceefc692356615a884ea Mon Sep 17 00:00:00 2001 From: "J. Ryan Stinnett" Date: Wed, 31 Jul 2019 11:10:49 +0100 Subject: [PATCH] Fix context when using subtree of components --- src/components/views/messages/MessageActionBar.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/components/views/messages/MessageActionBar.js b/src/components/views/messages/MessageActionBar.js index 8db268076cf..fb3c53c9f07 100644 --- a/src/components/views/messages/MessageActionBar.js +++ b/src/components/views/messages/MessageActionBar.js @@ -145,10 +145,12 @@ export default class MessageActionBar extends React.PureComponent { let editButton; if (isContentActionable(this.props.mxEvent)) { - if (this.context.room.canReact) { + // `context` can be null in tests that use a subtree of components + // that don't create the context. + if (!this.context || !this.context.room || this.context.room.canReact) { reactButton = this.renderReactButton(); } - if (this.context.room.canReply) { + if (!this.context || !this.context.room || this.context.room.canReply) { replyButton =