react-component / react-component/checkbox
expose `currentTarget` in `handleChange`
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 132
- Forks
- 109
- PR merge metrics
- No merged PRs in 30d
Description
Happy to send a PR :)
From react/flow docs:
Note: To get the element instance, like HTMLButtonElement in the example above, it is a common mistake to use event.target instead of event.currentTarget. The reason why you want to use event.currentTarget is that event.target may be the wrong element due to event propagation.
handleChange = (e) => {
const { props } = this;
if (props.disabled) {
return;
}
if (!('checked' in props)) {
this.setState({
checked: e.target.checked,
});
}
props.onChange({
+ currentTarget: e.currentTarget,
target: {
...props,
checked: e.target.checked,
},
stopPropagation() {
e.stopPropagation();
},
preventDefault() {
e.preventDefault();
},
nativeEvent: e.nativeEvent,
});
};
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in src/Checkbox.jsx at the handleChange entry point referenced by the issue, and compare the event object passed to props.onChange with the requested currentTarget addition. Verify that the callback exposes currentTarget while retaining the shown target and event methods, then run the repository's existing checks.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, react
- Domain
- frontend
- Issue type
- Feature
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100