-
Notifications
You must be signed in to change notification settings - Fork 679
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/range not updated #6
Conversation
Thank you @aommm :) i think it may be better if you use setRange method of the DateRange component instead setting the state directly while receiving new props. |
Good point, have done so now! |
Whoops. Noticed an error (in my code) when testing the latest commit. setRange also calls the onChange listener, and in my case, that listener updates the x and y properties. This in turn triggers a new setRange, and so on into infinity. Toy example of my setup:
If you have this setup and trigger a change of Proposal: What do you think about this? |
@aommm good point. sure we need a way to do silent changes and having |
@aommm is this ready to be merged? |
Yes, I've tested it and it behaves as expected.
|
thanks @aommm |
@aommm i'm reverting this back since it's breaking current behavior which can be reproduced in the demo app. If you run the demo app with your build and try to change the range manually (by clicking) you can see what's broken. |
This fixes #5.
This pull request listens for prop changes, and whenever any of those two properties change, we re-parse them.
Note/discussion:
this might be a problem for other properties as well, but I only solved it for my use case for now.
Ideally, we would perhaps restructure the code so that the dates information is not stored in two places (props and state). One could for instance store the dates only as props, and do the parsing of the dates only when needed (i.e. in render)