Comments (13)
i'll create an example so we have something to talk about, give me a bit.
from rheostat.
"on change" suggests to me that it should fire whenever there's been any change at all; the source of that change is irrelevant.
from rheostat.
Well maybe, but that's not how controlled input components work in react.. if they did we'd get into infinite loops by default wouldn't we? 😬
from rheostat.
A controlled input wouldn't have the value change except via user action; can you provide a repro case where you're getting onChange otherwise?
from rheostat.
Sure I'll make a webpack bin real quick (...in a few hours, train is just getting into work, sorry!)
Also - I'm actually changing the value
via user interaction (then updating state onChange
), as well as updating the value
programatically on a button press. Maybe that use case wasn't initially considered?
from rheostat.
"on a button press" is as a result of user interaction, why wouldn't that trigger onChange?
from rheostat.
@ljharb hey, made an example repo -> https://github.com/madou/rheostat-double-onchange
wanted to use webpack bin but it isn't working atm.
from the example - i would have thought rheostat wouldn't call onchange if i set the value outside of it. but it's calling it. whats your thoughts?
from rheostat.
Yup, it looks like onChange
is called whenever values change. The documentation states that onChange
is called when the values are "committed" which happens by drag, click, keyboard input, and props change.
We should maybe not do it when props change to your point of not having it trigger an infinite loop but I think that line is there for a reason.
Perhaps what we need is an event that fires only when the slider is changed in a non-programmatic way.
from rheostat.
hey! maybe.
i think the default expectation (well myself at least, haha) using controlled input components is it only gets triggered from the component itself trying to change. so i don't think it would be completely left field to make it do that.
breaking change though.
from rheostat.
@Madou Yes, I was expecting the same behavior as controlled inputs and it triggered infinite loop while setting values state programmatically.
I agree with the @goatslacker, we can add an event that only fires when the user interacts with the slider.
from rheostat.
Since onChange is called even when the props change, had to do a workaround as mentioned by @Madou. I second @goatslacker for adding an event that fires only when slider is changed by the user.
from rheostat.
I'm seeing the onChange
getting called when the min
/max
props changing, but not the values
. Perhaps the onChange
should only call if values
have changed from being outside min
/max
range 🤔
from rheostat.
We've also been dealing with this causing infinite loops, ended with a nextChangeIsReal
flag to implement @Madou 's suggestion.
It feels like an unexpected thing for the component do to compared to other controlled components
from rheostat.
Related Issues (20)
- [email protected]: Warning: componentWillReceiveProps has been renamed, and is not recommended for use HOT 4
- An in-range update of eslint-plugin-react is breaking the build 🚨 HOT 6
- An in-range update of storybook is breaking the build 🚨 HOT 38
- An in-range update of babel7 is breaking the build 🚨 HOT 28
- An in-range update of enzyme is breaking the build 🚨
- An in-range update of enzyme is breaking the build 🚨
- An in-range update of enzyme is breaking the build 🚨
- An in-range update of webpack is breaking the build 🚨 HOT 9
- An in-range update of eslint-plugin-jest is breaking the build 🚨 HOT 4
- Bundle size increased to almost 100Kb minified HOT 3
- An in-range update of eslint-plugin-import is breaking the build 🚨 HOT 3
- Aria-labels can't be added to slider buttons HOT 3
- DefaultHandle should allow children HOT 2
- can i use this library in react-native? HOT 1
- @types/rheostat values HOT 1
- An in-range update of style-loader is breaking the build 🚨 HOT 3
- RTL Support Doesn't Work HOT 6
- Background Chart Example HOT 2
- PropType warnings for not required props HOT 1
- Rheostat Functional Component HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rheostat.