diff --git a/mobile/views/Channel/index.js b/mobile/views/Channel/index.js index bb05f46760..b8634a7280 100644 --- a/mobile/views/Channel/index.js +++ b/mobile/views/Channel/index.js @@ -57,7 +57,8 @@ class Channel extends Component { } else { title = 'Loading channel...'; } - if (navigation.state.params.title === title) return; + const oldTitle = navigation.getParam('title', null); + if (oldTitle && oldTitle === title) return; navigation.setParams({ title }); }; diff --git a/mobile/views/Community/index.js b/mobile/views/Community/index.js index 3f54db93e7..2a989e13d5 100644 --- a/mobile/views/Community/index.js +++ b/mobile/views/Community/index.js @@ -78,7 +78,8 @@ class Community extends Component { } else { title = 'Loading community...'; } - if (navigation.state.params.title === title) return; + const oldTitle = navigation.getParam('title', null); + if (oldTitle && oldTitle === title) return; navigation.setParams({ title }); }; diff --git a/mobile/views/DirectMessageThread/components/DirectMessageThread.js b/mobile/views/DirectMessageThread/components/DirectMessageThread.js index 45ead568ed..08ab8e24e7 100644 --- a/mobile/views/DirectMessageThread/components/DirectMessageThread.js +++ b/mobile/views/DirectMessageThread/components/DirectMessageThread.js @@ -52,7 +52,8 @@ class DirectMessageThread extends Component { let title = directMessageThread ? sentencify(directMessageThread.participants.map(({ name }) => name)) : 'Loading thread...'; - if (navigation.state.params.title === title) return; + const oldTitle = navigation.getParam('title', null); + if (oldTitle && oldTitle === title) return; navigation.setParams({ title }); }; diff --git a/mobile/views/DirectMessageThread/index.js b/mobile/views/DirectMessageThread/index.js index 9668259d4d..ebae979dcf 100644 --- a/mobile/views/DirectMessageThread/index.js +++ b/mobile/views/DirectMessageThread/index.js @@ -1,7 +1,6 @@ // @flow import React from 'react'; import compose from 'recompose/compose'; -import idx from 'idx'; import Text from '../../components/Text'; import { withCurrentUser } from '../../components/WithCurrentUser'; import DirectMessageThread from './components/DirectMessageThread'; @@ -17,8 +16,8 @@ type Props = { class DirectMessageThreadView extends React.Component { render() { - const id = idx(this.props, props => props.navigation.state.params.id); const { currentUser, navigation } = this.props; + const id = navigation.getParam('id', null); if (!id) return Non-existant DM thread; if (!currentUser) return null; diff --git a/mobile/views/TabBar/BaseStack.js b/mobile/views/TabBar/BaseStack.js index 09d44d63b6..371196ef14 100644 --- a/mobile/views/TabBar/BaseStack.js +++ b/mobile/views/TabBar/BaseStack.js @@ -12,26 +12,26 @@ const BaseStack = { Thread: { screen: withMappedNavigationProps(Thread), navigationOptions: ({ navigation }: NavigationScreenConfigProps) => ({ - headerTitle: navigation.state.params.title || null, + headerTitle: navigation.getParam('title', null), tabBarVisible: false, }), }, Community: { screen: withMappedNavigationProps(Community), navigationOptions: ({ navigation }: NavigationScreenConfigProps) => ({ - headerTitle: navigation.state.params.title || null, + headerTitle: navigation.getParam('title', null), }), }, Channel: { screen: withMappedNavigationProps(Channel), navigationOptions: ({ navigation }: NavigationScreenConfigProps) => ({ - headerTitle: navigation.state.params.title || null, + headerTitle: navigation.getParam('title', null), }), }, User: { screen: withMappedNavigationProps(User), navigationOptions: ({ navigation }: NavigationScreenConfigProps) => ({ - headerTitle: navigation.state.params.title || null, + headerTitle: navigation.getParam('title', null), }), }, }; diff --git a/mobile/views/TabBar/DirectMessageStack.js b/mobile/views/TabBar/DirectMessageStack.js index 75278ce3b3..db52e60f7e 100644 --- a/mobile/views/TabBar/DirectMessageStack.js +++ b/mobile/views/TabBar/DirectMessageStack.js @@ -1,6 +1,5 @@ // @flow import { createStackNavigator } from 'react-navigation'; -import idx from 'idx'; import BaseStack from './BaseStack'; import DirectMessages from '../DirectMessages'; import DirectMessageThread from '../DirectMessageThread'; @@ -10,13 +9,13 @@ const DMStack = createStackNavigator( DirectMessages: { screen: DirectMessages, navigationOptions: ({ navigation }) => ({ - headerTitle: idx(navigation, _ => _.state.params.title) || 'Messages', + headerTitle: navigation.getParam('title', 'Messages'), }), }, DirectMessageThread: { screen: DirectMessageThread, navigationOptions: ({ navigation }) => ({ - headerTitle: idx(navigation, _ => _.state.params.title) || '', + headerTitle: navigation.getParam('title', null), tabBarVisible: false, }), }, diff --git a/mobile/views/Thread/index.js b/mobile/views/Thread/index.js index 69b67decc7..0f7260d2f6 100644 --- a/mobile/views/Thread/index.js +++ b/mobile/views/Thread/index.js @@ -59,7 +59,8 @@ class Thread extends Component { } else { title = 'Loading thread...'; } - if (navigation.state.params.title === title) return; + const oldTitle = navigation.getParam('title', null); + if (oldTitle && oldTitle === title) return; navigation.setParams({ title }); }; diff --git a/mobile/views/User/profile.js b/mobile/views/User/profile.js index 16cf372a5d..dc61e0a3d0 100644 --- a/mobile/views/User/profile.js +++ b/mobile/views/User/profile.js @@ -50,7 +50,9 @@ class User extends Component { } else { title = 'Loading user...'; } - if (navigation.state.params.title === title) return; + + const oldTitle = navigation.getParam('title', null); + if (oldTitle && oldTitle === title) return; navigation.setParams({ title }); };