-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
rerender country and state if visited via deep link #28404
Changes from 1 commit
5c23584
1c64c43
230bc39
7cc4535
5729e74
6f1b1c0
fe4ca57
f1f96bc
48c1939
7c03147
811deb9
c318647
237a589
1caf195
a9b6ed1
a70225e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -72,7 +72,6 @@ function AddressPage({privatePersonalDetails, route}) { | |
usePrivatePersonalDetails(); | ||
const {translate} = useLocalize(); | ||
const countryFromUrl = lodashGet(route, 'params.country'); | ||
const [currentCountry, setCurrentCountry] = useState(countryFromUrl || PersonalDetails.getCountryISO(lodashGet(privatePersonalDetails, 'address.country'))); | ||
const isUSAForm = currentCountry === CONST.COUNTRY.US; | ||
const zipSampleFormat = lodashGet(CONST.COUNTRY_ZIP_REGEX_DATA, [currentCountry, 'samples'], ''); | ||
const zipFormat = translate('common.zipCodeExampleFormat', {zipSampleFormat}); | ||
|
@@ -81,12 +80,23 @@ function AddressPage({privatePersonalDetails, route}) { | |
const isLoadingPersonalDetails = lodashGet(privatePersonalDetails, 'isLoading', true); | ||
const [street1, street2] = (address.street || '').split('\n'); | ||
const [state, setState] = useState(address.state); | ||
const [currentCountry, setCurrentCountry] = useState(PersonalDetails.getCountryISO(address.country)); | ||
|
||
saranshbalyan-1234 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
/** | ||
* @param {Function} translate - translate function | ||
* @param {Boolean} isUSAForm - selected country ISO code is US | ||
* @param {Object} values - form input values | ||
* @returns {Object} - An object containing the errors for each inputID | ||
*/ | ||
|
||
useEffect(() => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is the wrong place to put It should be placed after There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
if(!address) return | ||
setState(address.state) | ||
setCurrentCountry(address.country) | ||
}, [address]); | ||
saranshbalyan-1234 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
saranshbalyan-1234 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
const validate = useCallback((values) => { | ||
const errors = {}; | ||
const requiredFields = ['addressLine1', 'city', 'country', 'state']; | ||
|
@@ -256,4 +266,4 @@ export default withOnyx({ | |
privatePersonalDetails: { | ||
key: ONYXKEYS.PRIVATE_PERSONAL_DETAILS, | ||
}, | ||
})(AddressPage); | ||
})(AddressPage); | ||
saranshbalyan-1234 marked this conversation as resolved.
Show resolved
Hide resolved
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are some linter errors