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

Bug: Incorrect State Update Function in InputBox Component #140

Open
yash-sojitra-20 opened this issue Jun 18, 2024 · 0 comments
Open

Bug: Incorrect State Update Function in InputBox Component #140

yash-sojitra-20 opened this issue Jun 18, 2024 · 0 comments

Comments

@yash-sojitra-20
Copy link

There is an error in the App.js file where the InputBox component's onCurrencyChange prop incorrectly uses setAmount instead of setFrom. This causes the amount to be set rather than updating the currency. This needs to be corrected to ensure the currency selection updates properly.

Steps to Reproduce:

  • Clone the repository and set up the project.
  • Run the application.
  • Navigate to the section where the "From" currency input is located.
  • Try changing the currency in the "From" field.

Expected Behavior:

When the currency is changed in the "From" input, the setFrom state update function should be called to update the currency.

Actual Behavior:

The setAmount state update function is called instead, which incorrectly updates the amount rather than the currency.

Code Snippet:

Here is the specific part of the code with the error and the proposed fix:

<InputBox
    label="From"
    amount={amount}
    currencyOptions={options}
    onCurrencyChange={(currency) => setFrom(currency)} // Corrected function
    selectCurrency={from}
    onAmountChange={(amount) => setAmount(amount)}
/>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant