Skip to content

Commit

Permalink
Merge pull request #235 from beejunk/issue-233
Browse files Browse the repository at this point in the history
Derive chat state from props [#233].
  • Loading branch information
leeschumacher authored Aug 7, 2020
2 parents 5949d0b + 4902e1a commit ca33142
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions src/ui/game/GameScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,17 +48,25 @@ type State = {
};

export default class GameScreen extends Component<Props, State> {
static getDerivedStateFromProps(props: Props, state: State) {
let { chatSections } = state;
let { game } = props;
let currentChatSections = getGameChatSections(game);

if (chatSections.length !== currentChatSections.length) {
return { ...state, chatSections: currentChatSections };
}

return null;
}

state = {
tab: "chat",
chatSections: getGameChatSections(this.props.game),
chatSections: [],
};

_chatScrollRef: ?HTMLElement;

/* componentWillReceiveProps(nextProps: Props) {
this.setState({chatSections: getGameChatSections(nextProps.game)});
}*/

_setChatScroll = () => {
setTimeout(() => {
if (this._chatScrollRef) {
Expand Down

0 comments on commit ca33142

Please sign in to comment.