Skip to content
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

Can't wrap RefreshControl in a custom component on Android? #11784

Closed
jamesisaac opened this issue Jan 9, 2017 · 5 comments
Closed

Can't wrap RefreshControl in a custom component on Android? #11784

jamesisaac opened this issue Jan 9, 2017 · 5 comments
Labels
Resolution: Locked This issue was locked by the bot.

Comments

@jamesisaac
Copy link
Contributor

Description

If I want common swipe-to-refresh functionality to be re-used across several screens in my app (across both ListViews and ScrollViews), surely the cleanest solution to this would be to have a custom MyRefreshControl, which encapsulates its own state / syncing logic / styling, that can be composed in with a single line - refreshControl={<MyRefreshControl />}. But from what I can tell this doesn't seem to work.

Reproduction

https://rnplay.org/apps/41CAVQ

Example above works on iOS, but not Android. Uncommenting line 27 and commenting 28 (i.e. removing the custom component wrapper) fixes it for Android.

Additional Information

  • React Native version: 0.37.0 (Exponent latest)
  • Platform: Android
  • Operating System: Windows
@jamesisaac
Copy link
Contributor Author

jamesisaac commented Jan 13, 2017

Never mind - turns out the issue was that I wasn't passing {...this.props} down from my component to the original RefreshControl.

From the way it's called, it's not really clear that there are other props being implicitly passed on to the RefreshControl. Might be useful if that was mentioned in the docs, or there was an error if those props aren't being provided.

@aroth
Copy link
Contributor

aroth commented Aug 1, 2017

This caught me too. Thanks for following up with a resolution, @jamesisaac.

@BradRyan
Copy link

YES! Thank you @jamesisaac. Just saved me a ton of time.

@toytonic
Copy link

toytonic commented Apr 4, 2018

Hi @jamesisaac, is your example still available somewhere? I am trying to wrap the native refresh control within a custom component without success. When I put a container view around it, I get the following error:

Exception thrown while executing UI block: RCTScrollView may only contain a single subview

I basically want to add something similar as progressViewOffset for android. I already tried a lot but without success. Any help appreciated...

@jamesisaac
Copy link
Contributor Author

Hi @toytonic . I wasn't putting a view around it, just wrapping it in another React component so that I could pass in some props by default. By wrapping it in a view you're affecting the view hierarchy, which would have unknown consequences... not really related to this issue.

@facebook facebook locked as resolved and limited conversation to collaborators May 24, 2018
@react-native-bot react-native-bot added the Resolution: Locked This issue was locked by the bot. label Jul 19, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Resolution: Locked This issue was locked by the bot.
Projects
None yet
Development

No branches or pull requests

5 participants