Skip to content

Commit

Permalink
SnapshotViewIOS: Remove PropTypes (#21294)
Browse files Browse the repository at this point in the history
Summary:
Part of: react-native-community/discussions-and-proposals#29

This PR removes all PropTypes from `SnapshotViewIOS`, and fills out the flow types for its event callbacks.
Pull Request resolved: #21294

Differential Revision: D10011659

Pulled By: TheSavior

fbshipit-source-id: 28bfa0ab58c0655f9b905d3cb6530b57166c67f9
  • Loading branch information
empyrical authored and facebook-github-bot committed Sep 24, 2018
1 parent e0170a9 commit 93717e3
Showing 1 changed file with 16 additions and 15 deletions.
31 changes: 16 additions & 15 deletions Libraries/RCTTest/SnapshotViewIOS.ios.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@

'use strict';

const DeprecatedViewPropTypes = require('DeprecatedViewPropTypes');
const PropTypes = require('prop-types');
const React = require('React');
const StyleSheet = require('StyleSheet');
const UIManager = require('UIManager');
Expand All @@ -21,27 +19,30 @@ const requireNativeComponent = require('requireNativeComponent');

const {TestModule} = require('NativeModules');

import type {SyntheticEvent} from 'CoreEventTypes';
import type {ViewProps} from 'ViewPropTypes';

// Verify that RCTSnapshot is part of the UIManager since it is only loaded
// if you have linked against RCTTest like in tests, otherwise we will have
// a warning printed out
const RCTSnapshot = UIManager.RCTSnapshot
? requireNativeComponent('RCTSnapshot')
: View;

class SnapshotViewIOS extends React.Component<{
onSnapshotReady?: Function,
testIdentifier?: string,
}> {
// $FlowFixMe(>=0.41.0)
static propTypes = {
...DeprecatedViewPropTypes,
// A callback when the Snapshot view is ready to be compared
onSnapshotReady: PropTypes.func,
// A name to identify the individual instance to the SnapshotView
testIdentifier: PropTypes.string,
};
type SnapshotReadyEvent = SyntheticEvent<
$ReadOnly<{
testIdentifier: string,
}>,
>;

type Props = $ReadOnly<{|
...ViewProps,
onSnapshotReady?: ?(event: SnapshotReadyEvent) => mixed,
testIdentifier?: ?string,
|}>;

onDefaultAction = (event: Object) => {
class SnapshotViewIOS extends React.Component<Props> {
onDefaultAction = (event: SnapshotReadyEvent) => {
TestModule.verifySnapshot(TestModule.markTestPassed);
};

Expand Down

0 comments on commit 93717e3

Please sign in to comment.