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

onMinimumReached and onMaximumReached events are always fired #18

Open
misheki opened this issue Apr 6, 2018 · 4 comments
Open

onMinimumReached and onMaximumReached events are always fired #18

misheki opened this issue Apr 6, 2018 · 4 comments

Comments

@misheki
Copy link

misheki commented Apr 6, 2018

<UIStepper displayValue={true} initialValue={item.qty} minimumValue={1} maximumValue={10} value={item.qty} onMinimumReached={console.warn(' min reached')} onMaximumReached={console.warn(' max reached')} onIncrement={() => this.increment(item.id)} onDecrement={() => this.decrement(item.id)} />

The onMinimumReached and onMaximumReached events are always triggered upon render even when the value is 3.

By the way, my UIStepper is inside a FlatList (loop).

Am I lacking a setting?

@hannigand
Copy link
Owner

Thanks for reporting the issue @misheki

Have you got a repository or a reproducible demo that I could use to fix the issue?

@misheki
Copy link
Author

misheki commented Apr 19, 2018

Hi @hannigand, sorry for the late response.

I don't have a demo on this yet because I realized that it does not bother my requirements as of now. However, I am facing a different issue with the VALUE setting. Even though I hardcoded it with the number 3, it still increments and decrements when I click on the plus and minus buttons. Should I close this and open a new issue?

Thanks!

@hannigand
Copy link
Owner

hannigand commented Apr 19, 2018

Hi @misheki - that's the expected behaviour.

When you set the value, it is not read-only and you can modify it by pressing the increment/decrement buttons.

@marcpicaud
Copy link

Hey @misheki , instead of this ;
onMinimumReached={console.warn(' min reached')}

Please try this :
onMinimumReached={() => console.warn(' min reached')}

Passing a function instead of an instruction will prevent the behavior you're describing. Cf. https://reactjs.org/docs/faq-functions.html#why-is-my-function-being-called-every-time-the-component-renders

Cheers

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

3 participants