Skip to content

Commit

Permalink
Merge pull request #18944 from hoangzinh/df/18815
Browse files Browse the repository at this point in the history
Fix reload year search page, date search selection breaks in DOB page
  • Loading branch information
mountiny authored May 19, 2023
2 parents f27e8b4 + 9513439 commit 435c70b
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/pages/settings/Profile/PersonalDetails/DateOfBirthPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import * as PersonalDetails from '../../../../libs/actions/PersonalDetails';
import compose from '../../../../libs/compose';
import NewDatePicker from '../../../../components/NewDatePicker';
import CONST from '../../../../CONST';
import withNavigationFocus from '../../../../components/withNavigationFocus';

const propTypes = {
/* Onyx Props */
Expand Down Expand Up @@ -49,11 +50,16 @@ class DateOfBirthPage extends Component {
}

componentDidMount() {
this.props.navigation.addListener('focus', this.getYearFromRouteParams);
this.getYearFromRouteParams();
}

componentWillUnmount() {
this.props.navigation.removeListener('focus', this.getYearFromRouteParams);
componentDidUpdate(prevProps) {
// When we're navigating back from Year page. We need to update the selected year from the URL
if (prevProps.isFocused || !this.props.isFocused) {
return;
}

this.getYearFromRouteParams();
}

/**
Expand Down Expand Up @@ -135,6 +141,7 @@ DateOfBirthPage.defaultProps = defaultProps;

export default compose(
withLocalize,
withNavigationFocus,
withOnyx({
privatePersonalDetails: {
key: ONYXKEYS.PRIVATE_PERSONAL_DETAILS,
Expand Down

0 comments on commit 435c70b

Please sign in to comment.