Comments (6)
Great point.
@tleunen What do you think? Why did you decide to pass value to handler instead of original event?
from react-mdl.
Not sure that it's fired twice because of that though, AFAIK comments don't work like this in JSX.
@joshq00 Try removing it instead of commenting.
from react-mdl.
Re-writing this comment.
Essentially, the problem is that I couldn't stop the onChange
event from propagating.
handleChange ( checked ) {
// logic
// ...
// ...
this.props.onChange( this.state.checkedCount );
}
render () {
let { title, ...other } = this.props;
return (
<MyComponent { ...other }>
<h1>{ title }</h1>
<Checkbox label='option 1' onChange={ ::this.handleChange } />
</MyComponent>
);
}
Use <MyComponent onChange={ console.log } />
and it'll fire twice: once with checkedCount
, once with SyntheticEvent
.
It's hard to reason why: but it's because we trigger it, then the original onChange
from the checkbox propagates and fires on MyComponent
. But as a user, we never saw this because the handler is (under the covers) swallowing the event and letting it continue propagating. I'd normally have to stop that in 'handleChange'
from react-mdl.
Sorry for those repeated commits. Don't know if you expect one-commit merges. Had to do some tweaking tweaking with the demos
from react-mdl.
If accepted, should probably bump a minor version... As these will be breaking changes
from react-mdl.
@web2style once made a PR about the same kind of change: #25. It was accepted and then reverted.
But this one seems to be more consistant. It updates every component with the same behavior.
Initially, the reason why the value was only sent is because usually, that's the only information you care to receive. But I do understand sometimes you want more, or like in this case, you want the same function signature. So I agree to accept the PR. I'll do it later after a better look at it.
from react-mdl.
Related Issues (20)
- Library request on CDNJS HOT 3
- The prop `target` is marked as required in `Menu`
- React-MdL Dialog Not working in firefox and safari HOT 2
- Checkbox visibility
- Button ripple effect bug!?
- [TextField] Grey border-bottom doesn't disappear when field is clicked. Blue doesn't cover grey correctly. HOT 1
- DataTable: Is there any option to handle onSelectionChanged with out enabling selectable
- Should I use this project or react-toolbox? HOT 1
- Slider Tick Increments HOT 1
- Fix Circle CI and Codecov badges HOT 2
- [Typescript] Can you change this project to typescript ?
- [DataTable] accept nested objects in "rows" array HOT 1
- TypeError: Cannot read property 'upgradeElements' of undefined
- Where is the source code of react-mdl templates HOT 1
- how to get callback of click event on every single row in datatable
- Dialogs with input fields on mobile devices
- too many css files for WebStrom HOT 3
- 0
- Archive the repo? HOT 1
- "Uncaught Invariant Violation: Maximum update depth exceeded" in DataTable property onSelectionChanged Again
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 react-mdl.