Skip to content
This repository has been archived by the owner on Sep 24, 2020. It is now read-only.

Commit

Permalink
Fix: Crash, when navigate back to about when user open profile from a…
Browse files Browse the repository at this point in the history
…bout
  • Loading branch information
ovr committed Apr 6, 2018
1 parent e02e625 commit 70e1735
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 21 deletions.
20 changes: 20 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,26 @@

## Unreleased

### 0.12.1

Fixes:

- Crash, when navigate back to about when user open profile from about

### 0.12.0

Feature:

- AccountNotifications - rewrork on top of Realm
- Speedup application start
- AboutScreen - load contributors from JSON file
- AccountNotifications - improve sync
- Update vendors

Fixes:

- LoginScreen - disable autoCorrect for InputField

## 0.11.4

Feature:
Expand Down
12 changes: 6 additions & 6 deletions containers/Profile/Profile.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,16 @@ import { fetchProfile } from 'actions';

// import flow types
import type { ProfileState } from 'reducers/profile';
import type { NavigationState } from 'reducers/navigation';

type Props = {
profile: ProfileState,
navigation: NavigationState,
fetchProfile: typeof fetchProfile,
navigation: any
}

class Profile extends PureComponent<Props> {
componentWillMount() {
this.props.fetchProfile(this.props.navigation.params.id);
this.props.fetchProfile(this.props.navigation.getParam('id'));
}

render() {
Expand All @@ -39,7 +38,9 @@ class Profile extends PureComponent<Props> {
<View style={styles.container}>
<ErrorView
onPress={
() => this.props.fetchProfile(this.props.navigation.params.id)
() => this.props.fetchProfile(
this.props.navigation.getParam('id')
)
}
error={error}
refreshable={true}
Expand Down Expand Up @@ -79,8 +80,7 @@ export default connect(
(state) => {
return {
profile: state.profile,
profileOrganizations: state.profileOrganizations,
navigation: state.navigation
profileOrganizations: state.profileOrganizations
};
},
{ fetchProfile }
Expand Down
13 changes: 4 additions & 9 deletions containers/ProfileRepositories/ProfileRepositories.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,7 @@ import type { RepositoryEntity } from 'github-flow-js';
import type { ProfileRepositoriesState } from 'reducers/profile-repositories';

type Props = {
navigation: {
params: {
id: string
}
},
navigation: any,
state: ProfileRepositoriesState,
fetchRepositories: typeof fetchRepositories,
fetchMoreRepositories: typeof fetchMoreRepositories,
Expand All @@ -27,7 +23,7 @@ type Props = {

class ProfileRepositories extends PureComponent<Props> {
componentWillMount() {
this.props.fetchRepositories(this.props.navigation.params.id);
this.props.fetchRepositories(this.props.navigation.getParam('id'));
}

render() {
Expand All @@ -51,7 +47,7 @@ class ProfileRepositories extends PureComponent<Props> {

const { moreLoading, hasMore, page } = this.props.state;
const { showRepository, fetchMoreRepositories } = this.props;
const username = this.props.navigation.params.id;
const username = this.props.navigation.getParam('id');

return (
<FlatList
Expand Down Expand Up @@ -95,8 +91,7 @@ const styles = StyleSheet.create({
export default connect(
(state: State) => {
return {
state: state.profileRepositories,
navigation: state.navigation
state: state.profileRepositories
};
},
{ fetchRepositories, fetchMoreRepositories, showRepository }
Expand Down
18 changes: 12 additions & 6 deletions containers/ProfileScreen/ProfileScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import React, { PureComponent } from 'react';
import { View, StyleSheet } from 'react-native';
import { TabViewAnimated, TabBar, SceneMap } from 'react-native-tab-view';
import { TabViewAnimated, TabBar } from 'react-native-tab-view';
import { connect } from 'react-redux';

import { UIText } from 'components';
Expand Down Expand Up @@ -58,10 +58,16 @@ class ProfileScreen extends PureComponent<Props, ProfileScreenState> {
return null;
}

renderScene = SceneMap({
overview: Profile,
repositories: ProfileRepositories,
});
renderScene = ({ route }) => {
switch (route.key) {
case 'overview':
return <Profile {...this.props} />;
case 'repositories':
return <ProfileRepositories {...this.props} />;
default:
return null;
}
}

render() {
return (
Expand All @@ -71,6 +77,7 @@ class ProfileScreen extends PureComponent<Props, ProfileScreenState> {
renderHeader={this.renderHeader}
onIndexChange={this.handleIndexChange}
useNativeDriver
{...this.props}
/>
);
}
Expand All @@ -95,7 +102,6 @@ const styles = StyleSheet.create({
export default connect(
(state) => {
return {
navigation: state.navigation,
profile: state.profile
};
}
Expand Down

0 comments on commit 70e1735

Please sign in to comment.