Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
Remove usage of setNativeProps #10934
Remove usage of setNativeProps #10934
Changes from 26 commits
8666d97
ecabcfc
1295ebb
27020f5
72bbc0b
ddfabdf
12fa935
e45288e
e2b07d2
1cce3d5
4c90e34
1bfc4e2
a0ff498
8528c0d
deeaef9
b77ab39
3298fa7
28fdeac
38fd5ad
e23f51c
103e340
1192191
237d0dd
7dd836f
0644e1d
e0fb68b
a8b8e7b
97ebb65
5f1ecfe
b4d3bdd
74cb3cb
cbf0415
358a77f
aaab06b
2122178
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
Context - we have to remove usage of
setNativeProps
from app as a prereq to enabling Fabric.@marcaaron do you remember if there's any downside to pass this style as a prop vs using
setNativeProps
?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.
Good Change if this works. the
setnativeProps
were causing issues.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.
out of curiousity, do you remember what kind of issues?
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.
The concept of defaultValue is unnecessary when we are using state-bound value prop.
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.
Agree! I'll explain why I didn't remove it in this PR.
I think all Form components are state based / value prop driven. But Form.js passes
defaultValue
to all it's children anyway because it was designed to be uncontrolled.I reckon we should do the cleanup in a follow-up PR.
App/src/components/Form.js
Line 154 in 97ebb65
I wanted to avoid adding more tests or break anything basically
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.
For example,
StatePicker
usesdefaultValue
.We'd be introducing unrelated diffs and tests.
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.
Why?
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.
I don't know. Must be a mistake :))
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.
I think we should remove this
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.
did i do this right?
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.
Form passes a function to register this ref, so we should do something similar to this, no?
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.
How is this change related to this PR?
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.
Great question! @parasharrajat
Anytime a Form input's value is changed,
onInputChange()
is called.If you'll look at Form.js
App/src/components/Form.js
Lines 161 to 166 in 97ebb65
It keeps track of input values based on the key provided to it.
And this "key" is supposed to be the formID used by the Form input.
So our expected function call looks something like this -
onInputChange('Portugal', 'countryPicker')
Prerequisite: Picker is used in a Form.
Now
RNPickerSelect
comes into picture.It passes the picker item's index as the second parameter. (source)
So this is what actually gets called -
onInputChange('Portugal', 156)
. (where 156 is the index of Portugal in a list)Our Form based picker now will try to change the value of an input whose formID is 156.
And bam 💥 our Form based picker doesn't work anymore.
I'm just fixing this by passing the formID as the second param, because we don't care aobut the index lol
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.
This wasn't a problem before because previously, Form set the value using
ref.setNativeProps
.We're getting rid of that, so I had to fix Picker in this PR only.
App/src/components/Form.js
Line 166 in 1c78eb8
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.
We should add
value
to stateThere 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.
Let's make sure this issue doesn't come back
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.
yep, I have already added tests for it
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.
Can we remove other usages of
this.state.selectedTimezone
in this file?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.
Can't because it's controlled.
I now removed
defaultValue
, and passedvalue
.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.
This should be causing issues on Native if used. Even if this is used for the web, we can't put it into the global stylesheet. Use proper format for the transformation in react-native. In the future, someone can use it or can be confused by it.
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.
Oh yeahh, didn't think about it.
I'll see where it could be moved
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.
I think this is the correct format?
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.
Will have to verify. I'll breakup all this into multiple PRs.