[FIX] Intended direct mutation state running before initial state gets initiated (#1197)
This commit is contained in:
parent
8d4d522b63
commit
96eb86927a
|
@ -114,7 +114,9 @@ export default class NotificationPreferencesView extends React.Component {
|
|||
this.mounted = false;
|
||||
this.rid = props.navigation.getParam('rid');
|
||||
const room = props.navigation.getParam('room');
|
||||
|
||||
this.state = {
|
||||
room: room || {}
|
||||
};
|
||||
if (room && room.observe) {
|
||||
this.roomObservable = room.observe();
|
||||
this.subscription = this.roomObservable
|
||||
|
@ -126,10 +128,6 @@ export default class NotificationPreferencesView extends React.Component {
|
|||
}
|
||||
});
|
||||
}
|
||||
|
||||
this.state = {
|
||||
room: room || {}
|
||||
};
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
|
|
|
@ -43,19 +43,6 @@ class RoomActionsView extends React.Component {
|
|||
super(props);
|
||||
this.mounted = false;
|
||||
const room = props.navigation.getParam('room');
|
||||
|
||||
if (room && room.observe) {
|
||||
this.roomObservable = room.observe();
|
||||
this.subscription = this.roomObservable
|
||||
.subscribe((changes) => {
|
||||
if (this.mounted) {
|
||||
this.setState({ room: changes });
|
||||
} else {
|
||||
this.state.room = changes;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
this.rid = props.navigation.getParam('rid');
|
||||
this.t = props.navigation.getParam('t');
|
||||
this.state = {
|
||||
|
@ -67,6 +54,17 @@ class RoomActionsView extends React.Component {
|
|||
canAutoTranslate: false,
|
||||
canAddUser: false
|
||||
};
|
||||
if (room && room.observe) {
|
||||
this.roomObservable = room.observe();
|
||||
this.subscription = this.roomObservable
|
||||
.subscribe((changes) => {
|
||||
if (this.mounted) {
|
||||
this.setState({ room: changes });
|
||||
} else {
|
||||
this.state.room = changes;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
async componentDidMount() {
|
||||
|
|
|
@ -57,20 +57,7 @@ class RoomMembersView extends React.Component {
|
|||
this.MUTE_INDEX = 1;
|
||||
this.actionSheetOptions = [''];
|
||||
const { rid } = props.navigation.state.params;
|
||||
|
||||
const room = props.navigation.getParam('room');
|
||||
if (room && room.observe) {
|
||||
this.roomObservable = room.observe();
|
||||
this.subscription = this.roomObservable
|
||||
.subscribe((changes) => {
|
||||
if (this.mounted) {
|
||||
this.setState({ room: changes });
|
||||
} else {
|
||||
this.state.room = changes;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
this.state = {
|
||||
isLoading: false,
|
||||
allUsers: false,
|
||||
|
@ -82,6 +69,17 @@ class RoomMembersView extends React.Component {
|
|||
room: room || {},
|
||||
end: false
|
||||
};
|
||||
if (room && room.observe) {
|
||||
this.roomObservable = room.observe();
|
||||
this.subscription = this.roomObservable
|
||||
.subscribe((changes) => {
|
||||
if (this.mounted) {
|
||||
this.setState({ room: changes });
|
||||
} else {
|
||||
this.state.room = changes;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
async componentDidMount() {
|
||||
|
|
|
@ -76,10 +76,10 @@ class UploadProgress extends Component {
|
|||
super(props);
|
||||
this.mounted = false;
|
||||
this.ranInitialUploadCheck = false;
|
||||
this.init();
|
||||
this.state = {
|
||||
uploads: []
|
||||
};
|
||||
this.init();
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
|
|
|
@ -43,12 +43,12 @@ class ThreadMessagesView extends React.Component {
|
|||
this.mounted = false;
|
||||
this.rid = props.navigation.getParam('rid');
|
||||
this.t = props.navigation.getParam('t');
|
||||
this.subscribeData();
|
||||
this.state = {
|
||||
loading: false,
|
||||
end: false,
|
||||
messages: []
|
||||
};
|
||||
this.subscribeData();
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
|
|
Loading…
Reference in New Issue