-
Notifications
You must be signed in to change notification settings - Fork 24.4k
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
Support RefreshControl in RecyclerViewBackedScrollView in Android #8639
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -113,6 +113,18 @@ var RecyclerViewBackedScrollView = React.createClass({ | |
); | ||
}); | ||
|
||
const refreshControl = this.props.refreshControl; | ||
if (refreshControl) { | ||
// Wrap the NativeAndroidRecyclerView with a AndroidSwipeRefreshLayout. | ||
return React.cloneElement( | ||
refreshControl, | ||
{style: props.style}, | ||
<NativeAndroidRecyclerView {...props}> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you add a style with There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This style is already in props. console.log('props.style', props.style[0])
=> props.style Object {flex: 1} There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm mostly concerned about passing props.style to both AndroidSwipeRefreshLayout and NativeAndroidRecyclerView. Styles like margin could cause issues because they will get applied twice. Adding style after ...props will prevent that. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok, got it. Just added the style in the last commit. |
||
{wrappedChildren} | ||
</NativeAndroidRecyclerView> | ||
); | ||
} | ||
|
||
return ( | ||
<NativeAndroidRecyclerView {...props}> | ||
{wrappedChildren} | ||
|
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 you remove props.style above in the
props
definition and instead pass inthis.props.style
(and add flex: 1 if it's necessary).And set
style
in theprops
definition above to just{flex: 1}
.Also rename
props
torecyclerProps
.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.
Sorry, i'm a litte bit confused... it should became something like 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.
I think the clearer way to do this is not include style in the
props
declaration (line 95). This way we can be explicit about what style we want for each case.Should look like
styles.base
being{flex: 1}
We'll also have to change the case where there is no refreshControl to
style={[styles.base, this.props.style]}
and{...recyclerProps}
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.
Yeah, one way to think of it is: how would this code be most clearly written from scratch?
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.
Ok, I've understood now, it is more clear indeed. Just pushed the changes.