You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[TouchableHighlight] Automatically forward setNativeProps to the root subcomponent #97
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<Subcomponentref="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.
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.
changed the title [-]Automatically forward setNativeProps to the root subcomponent[/-][+][TouchableHighlight] Automatically forward setNativeProps to the root subcomponent[/+]on May 31, 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.
Activity
sahrens commentedon Feb 25, 2015
Yeah, we want to do this but don't think we ever got around to it.
brentvatne commentedon May 31, 2015
This seems useful!
[-]Automatically forward setNativeProps to the root subcomponent[/-][+][TouchableHighlight] Automatically forward setNativeProps to the root subcomponent[/+]ide commentedon 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 commentedon Jan 2, 2016
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
fix: use a shadow instead of a border for header on iOS