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

[TouchableHighlight] Automatically forward setNativeProps to the root subcomponent #97

Closed
ide opened this issue Feb 25, 2015 · 4 comments
Labels
Good first issue Interested in collaborating? Take a stab at fixing one of these issues. Resolution: Locked This issue was locked by the bot.

Comments

@ide
Copy link
Contributor

ide commented Feb 25, 2015

TouchableHighlight calls setNativeProps on its child, which is automatically handled by native views but not user-level composite components. In the examples I can think of off the top of my head, you'd typically want a composite component to forward setNativeProps to its root subcomponent i.e. the implementation looks like:

setNativeProps(nativeProps) {
  this.refs['root'].setNativeProps(nativeProps);
}
render() {
  return <Subcomponent ref="root">...</Subcomponent>;
  // If Subcomponent is composite, it will recursively forward setNativeProps
}

I propose this to be the default implementation if a component does not implement setNativeProps. This retains flexibility while I believe behaving reasonably in the default case.

@sahrens
Copy link
Contributor

sahrens commented Feb 25, 2015

Yeah, we want to do this but don't think we ever got around to it.

On Feb 24, 2015, at 11:32 PM, James Ide notifications@github.com wrote:

TouchableHighlight calls setNativeProps on its child, which is automatically handled by native views but not user-level composite components. In the examples I can think of off the top of my head, you'd typically want a composite component to forward setNativeProps to its root subcomponent i.e. the implementation looks like:

setNativeProps(nativeProps) {
this.refs['root'].setNativeProps(nativeProps);
}
render() {
return ...;
// If Subcomponent is composite, it will recursively forward setNativeProps
}
I propose this to be the default implementation if a component does not implement setNativeProps. This retains flexibility while I believe behaving reasonably in the default case.


Reply to this email directly or view it on GitHub.

@brentvatne
Copy link
Collaborator

This seems useful!

@brentvatne brentvatne changed the title Automatically forward setNativeProps to the root subcomponent [TouchableHighlight] Automatically forward setNativeProps to the root subcomponent May 31, 2015
@brentvatne brentvatne added the Good first issue Interested in collaborating? Take a stab at fixing one of these issues. label May 31, 2015
@ide
Copy link
Contributor Author

ide commented Jun 1, 2015

Feels like this would result in a change to React since the component renderer would need to hook up each owner's setNativeProps to the root it owns. Perhaps there is a less intrusive way with a mixin that we can experiment with and then make the change to React once we understand the space better. I think there is something useful here with automatic proxying between the owner and its root, like making onLayout work for composite components as well.

@brentvatne
Copy link
Collaborator

Hi there! This issue is being closed because it has been inactive for a while.

But don't worry, it will live on with ProductPains! Check out it's new home: https://productpains.com/post/react-native/touchablehighlight-automatically-forward-setnativeprops-to-the-root-subcomponent

@facebook facebook locked as resolved and limited conversation to collaborators Jul 23, 2018
@react-native-bot react-native-bot added the Resolution: Locked This issue was locked by the bot. label Jul 23, 2018
react-one pushed a commit to react-one/react-native that referenced this issue Sep 24, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Good first issue Interested in collaborating? Take a stab at fixing one of these issues. Resolution: Locked This issue was locked by the bot.
Projects
None yet
Development

No branches or pull requests

4 participants