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

Expose root ref by default to allow automatic forwarding of setNativeProps #8447

Closed
bitmage opened this issue Nov 28, 2016 · 1 comment
Closed

Comments

@bitmage
Copy link

bitmage commented Nov 28, 2016

In React Native, TouchableHighlight requires its children to forward 'setNativeProps'. This is implemented in built-in components, but must be manually implemented for all custom components.

This causes big incompatibilities with a library like Native Base, not to mention any custom components that the developer creates, which is apparently a preferred pattern for theming:

For our projects, we create a common directory inside the main js directory. This folder houses commonly-reused components throughout the app. For example, we can declare common Text and Header components...

It could be remedied by making available a default ref root which points to the root node. This would allow generic forwarding to be written into a base class, which other components could inherit from:

setNativeProps(props) {
  this.refs.root.setNativeProps(props)
}

This would essentially forward the props down the chain until we hit a "concrete" built-in component. Any arguments against making a root ref available by default?

@gaearon
Copy link
Collaborator

gaearon commented Oct 4, 2017

Yes, refs are not free, and making them always available is going to hurt performance and memory usage.

Maybe in the future this could be solved by #4213.

@gaearon gaearon closed this as completed Oct 4, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants