Skip to content

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

Closed

Description

@ide

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.

Activity

  1. sahrens commented on Feb 25, 2015

    @sahrens
    Contributor

    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.

  2. brentvatne commented on May 31, 2015

    @brentvatne
    Collaborator

    This seems useful!

  3. changed the title [-]Automatically forward setNativeProps to the root subcomponent[/-] [+][TouchableHighlight] Automatically forward setNativeProps to the root subcomponent[/+] on May 31, 2015
  4. added
    Good first issueInterested in collaborating? Take a stab at fixing one of these issues.
    on May 31, 2015
  5. ide commented on Jun 1, 2015

    @ide
    ContributorAuthor

    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.

  6. brentvatne commented on Jan 2, 2016

    @brentvatne
    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

  7. locked as resolved and limited conversation to collaborators on Jul 23, 2018
  8. added a commit that references this issue on Sep 24, 2021
    6e9d05b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Good first issueInterested in collaborating? Take a stab at fixing one of these issues.Resolution: LockedThis issue was locked by the bot.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions