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

Added constraint of child type to touchablewithoutfeedback #517

Closed
wants to merge 1 commit into from
Closed

Added constraint of child type to touchablewithoutfeedback #517

wants to merge 1 commit into from

Conversation

dzannotti
Copy link
Contributor

Added constraint of child type to touchablewithoutfeedback to match touchablehighlight (this would have failed silently previously), also added the cloneWithProps as by note of @vjeux

@@ -78,8 +88,15 @@ var TouchableWithoutFeedback = React.createClass({
},

render: function(): ReactElement {
// Note(vjeux): use cloneWithProps once React has been upgraded
var child = onlyChild(this.props.children);
var child = cloneWithProps(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, can you use React.cloneElement, cloneWithProps isn't working because it blows away the key

@dzannotti
Copy link
Contributor Author

It's the same code that is used on touchablehighlights currently i believe. Maybe i should revise both and add them to this commit?

@vjeux
Copy link
Contributor

vjeux commented Mar 30, 2015

Yeah would be nice, thanks

@dzannotti
Copy link
Contributor Author

Uhm... i think that actually cloneWithProps in this instance should be removed (maybe?) either way it gets cloned again 3 lines below https://github.com/dzannotti/react-native/blob/master/Libraries/Components/Touchable/TouchableWithoutFeedback.js#L101

All i know is that it silently failed to me, without this check, and it does not now. No side effects.

@sahrens for reference

@dzannotti
Copy link
Contributor Author

Any news on this? Would like to get this merged in, as currently using TouchableWithouFeedback without a native child view fails silently.

@vjeux
Copy link
Contributor

vjeux commented Apr 6, 2015

I pulled in your change but it actually broke some internal code. But looking at it more, I'm not sure I understand why you even need to do ensureIsNative here. On the other Touchable elements it makes sense because the component does setNativeProps on the ref, but this one doesn't.

@dzannotti
Copy link
Contributor Author

It silently fails without the check, which internal code did it break? in all my tests it worked as expected, but things might have changed since i made this PR

@vjeux
Copy link
Contributor

vjeux commented Apr 6, 2015

"It silently fails without the check" what silently fails?

@dzannotti
Copy link
Contributor Author

any non native components wrapped into TouchableWithoutFeedback don't receive any onPress events unless the onlychild is View

@vjeux
Copy link
Contributor

vjeux commented Apr 6, 2015

I see what you mean! Need to figure out what the best way to handle this, but I disagree that enforcing that children are native components is the right call.

<TouchableWithoutFeedback>
  <MyBigComponent />
</TouchableWithoutFeedback>

should be able to work, otherwise you break the ability to build abstractions.

@ide
Copy link
Contributor

ide commented Apr 6, 2015

@vjeux it works, you just need to implement setNativeProps I believe. #97 might be a better fix.

@dzannotti
Copy link
Contributor Author

@vjeux that's how it's done on TouchableWithHighlight

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Apr 7, 2015
@vjeux vjeux closed this in 76c86c8 Apr 13, 2015
vjeux pushed a commit to vjeux/react-native that referenced this pull request Apr 14, 2015
Summary:
Added constraint of child type to touchablewithoutfeedback to match touchablehighlight (this would have failed silently previously), also added the cloneWithProps as by note of @vjeux
Closes facebook#517
Github Author: Daniele Zannotti <d.zannotti@me.com>

Test Plan: Imported from GitHub, without a `Test Plan:` line.
vjeux pushed a commit to vjeux/react-native that referenced this pull request Apr 15, 2015
Summary:
Added constraint of child type to touchablewithoutfeedback to match touchablehighlight (this would have failed silently previously), also added the cloneWithProps as by note of @vjeux
Closes facebook#517
Github Author: Daniele Zannotti <d.zannotti@me.com>

Test Plan: Imported from GitHub, without a `Test Plan:` line.
jfrolich pushed a commit to jfrolich/react-native that referenced this pull request Apr 22, 2020
ayushjainrksh referenced this pull request in MLH-Fellowship/react-native Jul 2, 2020
Using `export PATH=$PATH:$ANDROID_HOME/emulator` instead of  `export PATH=$PATH:$ANDROID_HOME/tools` Because of Android Studio Emulator path Update, (https://stackoverflow.com/questions/40931254/could-not-launch-emulator-in-android-studio/51902207#51902207)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants