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

NumericInput showing a 0 instead of the real value, but then works onChange #10

Closed
zedtux opened this issue Sep 12, 2018 · 3 comments
Closed

Comments

@zedtux
Copy link

zedtux commented Sep 12, 2018

So I'm using <NumericInput> as the following :

                  <Text style={styles.TextColorGrey}>
                    {productStock.name}
                    {` (${stocks[productStock.id]} ${typeof stocks[productStock.id]})`}
                  </Text>
                  <NumericInput
                    minValue={0}
                    onChange={value => this.updateStockQuantity(productStock.id, value)}
                    value={stocks[productStock.id]}
                  />

And here is what is happening :

numericinput-bug

So basically the displayed value is 0, while it should be 3, then touching the plus button shows 4.
From the source code I found that you where doing a different treatment if the value is a number or not (that's why I'm showing the value type which is a number here), but it seems like you're not using the const value afterward but the this.state.stringValue.

@himelbrand
Copy link
Owner

@zedtux thanks for the response,
but since the last version initValue prop is required if you want to start with a different value from 0.
so you need to do this:

 <Text style={styles.TextColorGrey}>
                    {productStock.name}
                    {` (${stocks[productStock.id]} ${typeof stocks[productStock.id]})`}
                  </Text>
                  <NumericInput
                    minValue={0}
                    initValue={{stocks[productStock.id]}
                    onChange={value => this.updateStockQuantity(productStock.id, value)}
                    value={stocks[productStock.id]}
                  />

@zedtux
Copy link
Author

zedtux commented Sep 12, 2018

Oh, great @himelbrand thank you very much ! I'll try it.

@zedtux
Copy link
Author

zedtux commented Sep 12, 2018

I confirm this is working ! Nice, thank you !

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

2 participants