profile edit migrate to useNavigation

This commit is contained in:
noumantahir 2022-10-19 13:14:02 +05:00
parent 5c582768a9
commit ca4d95c4cf
2 changed files with 12 additions and 7 deletions

View File

@ -1,16 +1,16 @@
import { Component } from 'react';
import React, { Component } from 'react';
import { Alert } from 'react-native';
import { connect } from 'react-redux';
import { injectIntl } from 'react-intl';
import ImagePicker from 'react-native-image-crop-picker';
import get from 'lodash/get';
import { withNavigation } from '@react-navigation/compat';
import { uploadImage } from '../providers/ecency/ecency';
import { profileUpdate, signImage } from '../providers/hive/dhive';
import { updateCurrentAccount } from '../redux/actions/accountAction';
import { setAvatarCacheStamp } from '../redux/actions/uiAction';
import { useNavigation } from '@react-navigation/native';
// import ROUTES from '../constants/routeNames';
@ -145,7 +145,7 @@ class ProfileEditContainer extends Component {
};
_handleOnSubmit = async () => {
const { currentAccount, pinCode, dispatch, navigation, intl } = this.props;
const { currentAccount, pinCode, dispatch, navigation, intl, route} = this.props;
const { name, location, website, about, coverUrl, avatarUrl, pinned } = this.state;
this.setState({ isLoading: true });
@ -171,7 +171,7 @@ class ProfileEditContainer extends Component {
dispatch(updateCurrentAccount(_currentAccount));
dispatch(setAvatarCacheStamp(new Date().getTime()));
this.setState({ isLoading: false });
navigation.state.params.fetchUser();
route.params.fetchUser();
navigation.goBack();
} catch (err) {
Alert.alert(
@ -227,7 +227,12 @@ const mapStateToProps = (state) => ({
pinCode: state.application.pin,
});
export default connect(mapStateToProps)(injectIntl(withNavigation(ProfileEditContainer)));
const mapHooksToProps = (props) => ({
...props,
navigation:useNavigation()
})
export default connect(mapStateToProps)(injectIntl((props)=><ProfileEditContainer {...mapHooksToProps(props)}/>));
const IMAGE_PICKER_AVATAR_OPTIONS = {
includeBase64: true,

View File

@ -33,11 +33,11 @@ class ProfileEditScreen extends PureComponent {
};
render() {
const { intl } = this.props;
const { intl, route } = this.props;
const { selectedUploadAction } = this.state;
return (
<ProfileEditContainer>
<ProfileEditContainer route={route}>
{({
currentAccount,
isDarkTheme,