Skip to content
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

Fix currency changes after refresh although URL has currency params #23636

Merged
merged 4 commits into from
Aug 2, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 7 additions & 9 deletions src/pages/iou/steps/MoneyRequestAmountPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ function MoneyRequestAmountPage(props) {
const isEditing = useRef(lodashGet(props.route, 'path', '').includes('amount'));

const [amount, setAmount] = useState(selectedAmountAsString);
const [selectedCurrencyCode, setSelectedCurrencyCode] = useState(props.iou.currency);
const [selectedCurrencyCode, setSelectedCurrencyCode] = useState(props.iou.currency || CONST.CURRENCY.USD);
const [shouldUpdateSelection, setShouldUpdateSelection] = useState(true);
const [selection, setSelection] = useState({start: selectedAmountAsString.length, end: selectedAmountAsString.length});

Expand Down Expand Up @@ -276,16 +276,14 @@ function MoneyRequestAmountPage(props) {
}, [props.iou.participants, props.iou.amount, props.iou.id]);

useEffect(() => {
if (!props.route.params.currency) {
if (props.route.params.currency) {
setSelectedCurrencyCode(props.route.params.currency);
return;
}

setSelectedCurrencyCode(props.route.params.currency);
}, [props.route.params.currency]);

useEffect(() => {
setSelectedCurrencyCode(props.iou.currency);
}, [props.iou.currency]);
if (props.iou.currency) {
setSelectedCurrencyCode(props.iou.currency);
makiour marked this conversation as resolved.
Show resolved Hide resolved
}
}, [props.route.params.currency, props.iou.currency]);

useEffect(() => {
saveAmountToState(props.iou.currency, props.iou.amount);
Expand Down
Loading