Skip to content

Commit f46c5dc

Browse files
empyricalfacebook-github-bot
authored andcommitted
SnapshotViewIOS: Remove PropTypes (facebook#21294)
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: facebook#21294 Differential Revision: D10011659 Pulled By: TheSavior fbshipit-source-id: 28bfa0ab58c0655f9b905d3cb6530b57166c67f9
1 parent f3e418f commit f46c5dc

File tree

1 file changed

+16
-15
lines changed

1 file changed

+16
-15
lines changed

Libraries/RCTTest/SnapshotViewIOS.ios.js

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010

1111
'use strict';
1212

13-
const DeprecatedViewPropTypes = require('DeprecatedViewPropTypes');
14-
const PropTypes = require('prop-types');
1513
const React = require('React');
1614
const StyleSheet = require('StyleSheet');
1715
const UIManager = require('UIManager');
@@ -21,27 +19,30 @@ const requireNativeComponent = require('requireNativeComponent');
2119

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

22+
import type {SyntheticEvent} from 'CoreEventTypes';
23+
import type {ViewProps} from 'ViewPropTypes';
24+
2425
// Verify that RCTSnapshot is part of the UIManager since it is only loaded
2526
// if you have linked against RCTTest like in tests, otherwise we will have
2627
// a warning printed out
2728
const RCTSnapshot = UIManager.RCTSnapshot
2829
? requireNativeComponent('RCTSnapshot')
2930
: View;
3031

31-
class SnapshotViewIOS extends React.Component<{
32-
onSnapshotReady?: Function,
33-
testIdentifier?: string,
34-
}> {
35-
// $FlowFixMe(>=0.41.0)
36-
static propTypes = {
37-
...DeprecatedViewPropTypes,
38-
// A callback when the Snapshot view is ready to be compared
39-
onSnapshotReady: PropTypes.func,
40-
// A name to identify the individual instance to the SnapshotView
41-
testIdentifier: PropTypes.string,
42-
};
32+
type SnapshotReadyEvent = SyntheticEvent<
33+
$ReadOnly<{
34+
testIdentifier: string,
35+
}>,
36+
>;
37+
38+
type Props = $ReadOnly<{|
39+
...ViewProps,
40+
onSnapshotReady?: ?(event: SnapshotReadyEvent) => mixed,
41+
testIdentifier?: ?string,
42+
|}>;
4343

44-
onDefaultAction = (event: Object) => {
44+
class SnapshotViewIOS extends React.Component<Props> {
45+
onDefaultAction = (event: SnapshotReadyEvent) => {
4546
TestModule.verifySnapshot(TestModule.markTestPassed);
4647
};
4748

0 commit comments

Comments
 (0)