Skip to content

Commit

Permalink
Fix TouchablePreview regression (#6424)
Browse files Browse the repository at this point in the history
This PR includes:
- Ensuring the `onPress` or `onPressIn` props are not being overriden in `Navigation.TouchablePreview` as the internal `onPress` and `onPressIn` are handling the touch.
- Revert the `Button` component in the Playground app to class component to provide access to `ref`. 

Related to #6420 

This PR does fix triggering the `Preview` API in the Playground app however the Preview is still not appearing.
  • Loading branch information
jinshin1013 committed Jul 26, 2020
1 parent e3ec090 commit 2b42902
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 12 deletions.
2 changes: 1 addition & 1 deletion lib/src/adapters/TouchablePreview.tsx
Expand Up @@ -131,7 +131,7 @@ export class TouchablePreview extends React.PureComponent<Props> {
* Ignoring this for now so that it builds.
*/
// @ts-ignore
<Touchable ref={this.onRef} onPress={this.onPress} onPressIn={this.onPressIn} {...props}>
<Touchable {...props} ref={this.onRef} onPress={this.onPress} onPressIn={this.onPressIn}>
<View
onTouchStart={this.onTouchStart}
onTouchMove={this.onTouchMove as (event: GestureResponderEvent) => void}
Expand Down
28 changes: 17 additions & 11 deletions playground/src/components/Button.tsx
Expand Up @@ -14,15 +14,21 @@ type RnnButtonProps = {
testID?: string;
};

const RnnButton = ({ platform, testID, ...props }: RnnButtonProps) => {
// If the platform prop is provided, only render if provided platform matches the current platform.
if (platform && platform !== Platform.OS) {
return null;
}

return (
<Button {...props} testID={testID} backgroundColor={testID ? undefined : '#65C888'} marginB-8 />
);
};
export default class RnnButton extends React.Component<RnnButtonProps> {
render() {
const { platform, testID, ...props } = this.props;
// If the platform prop is provided, only render if provided platform matches the current platform.
if (platform && platform !== Platform.OS) {
return null;
}

export default RnnButton;
return (
<Button
{...props}
testID={testID}
backgroundColor={testID ? undefined : '#65C888'}
marginB-8
/>
);
}
}

0 comments on commit 2b42902

Please sign in to comment.