[FIX] Handle TypeErrors on navigationRef and draftMessage due to null properties (#2232)

Co-authored-by: Diego Mello <diegolmello@gmail.com>
This commit is contained in:
Youssef Muhamad 2020-07-02 14:10:11 -03:00 committed by GitHub
parent bf63014a6a
commit 68e9e1455b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 4 additions and 4 deletions

View File

@ -44,7 +44,7 @@ const App = React.memo(({ root, isMasterDetail }) => {
const navTheme = navigationTheme(theme); const navTheme = navigationTheme(theme);
React.useEffect(() => { React.useEffect(() => {
const state = Navigation.navigationRef.current.getRootState(); const state = Navigation.navigationRef.current?.getRootState();
const currentRouteName = getActiveRouteName(state); const currentRouteName = getActiveRouteName(state);
Navigation.routeNameRef.current = currentRouteName; Navigation.routeNameRef.current = currentRouteName;
setCurrentScreen(currentRouteName); setCurrentScreen(currentRouteName);

View File

@ -11,7 +11,7 @@ export const INAPP_NOTIFICATION_EMITTER = 'NotificationInApp';
const InAppNotification = memo(() => { const InAppNotification = memo(() => {
const show = (notification) => { const show = (notification) => {
const { payload } = notification; const { payload } = notification;
const state = Navigation.navigationRef.current.getRootState(); const state = Navigation.navigationRef.current?.getRootState();
const route = getActiveRoute(state); const route = getActiveRoute(state);
if (payload.rid) { if (payload.rid) {
if (route?.name === 'RoomView' && route.params?.rid === payload.rid) { if (route?.name === 'RoomView' && route.params?.rid === payload.rid) {

View File

@ -196,7 +196,7 @@ class MessageBox extends Component {
console.log('Messagebox.didMount: Thread not found'); console.log('Messagebox.didMount: Thread not found');
} }
} else if (!sharing) { } else if (!sharing) {
msg = this.room.draftMessage; msg = this.room?.draftMessage;
} }
} catch (e) { } catch (e) {
log(e); log(e);

View File

@ -150,7 +150,7 @@ class Root extends React.Component {
this.setState({ root: 'outside' }); this.setState({ root: 'outside' });
} }
const state = Navigation.navigationRef.current.getRootState(); const state = Navigation.navigationRef.current?.getRootState();
const currentRouteName = getActiveRouteName(state); const currentRouteName = getActiveRouteName(state);
Navigation.routeNameRef.current = currentRouteName; Navigation.routeNameRef.current = currentRouteName;
setCurrentScreen(currentRouteName); setCurrentScreen(currentRouteName);