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
Skip adding preventDefault to onChange events in React Native #3460
Conversation
Codecov Report
@@ Coverage Diff @@
## master #3460 +/- ##
==========================================
- Coverage 100% 99.93% -0.07%
==========================================
Files 68 68
Lines 1531 1533 +2
==========================================
+ Hits 1531 1532 +1
- Misses 0 1 +1
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reading thru facebook/react-native#5507, it seems like the solution is Object.defineProperty
.
Only one user claimed to have issues with it. Have you tried using it?
And, even though no tests broke, the coverage decreased, what means at least one test should be written 😄
@gustavohenke Yep, I've already tried it, and with it I only achieved to delay the error: instead of appearing at the first change, it would appear at the second. |
As per the tests, you're actually right, here's my plan. onChange(
{
...event,
preventDefault: () => {
defaultPrevented = true
return eventPreventDefault(event)
}
},
newValue,
previousValue
) My issue is that I have no idea on how to emulate RN's TextInput's event. Would you mind helping me with the test? @gustavohenke |
@erikras this PR is used in production by me with no issues whatsoever, but unfortunately I wasn't able to create a test for this PR (to avoid codecov alerts). |
Hmm... I'm seeing 100% code coverage when I run it locally. I'm going to merge and then fix any codecov problems later. |
Published in |
…nts issue redux-form#3489 locking version of immutable
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Bug
When using onChange in React Native, the users are faced with a couple possible error messages, as seen in #3153 and #3238.
This is due to the fact that it doesn't seem to be possible to properly extends React Native's event ( facebook/react-native#5507). My proposal is to skip adding .preventDefault to TextInput's onChange's event.
Tests
No test was broken
Eslint
Linting was respected
Closes #3153, closes #3238