mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Migrate rn-tester/IntegrationTests/SimpleSnapshotTest.js to function components (#48700)
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/48700 As per title. Changelog: [Internal] Reviewed By: rshest Differential Revision: D68152855 fbshipit-source-id: 121cb5dd65673121a021da12d10c7a7e118bd0dc
This commit is contained in:
committed by
Facebook GitHub Bot
parent
086e93d227
commit
8c64e0868e
@@ -10,32 +10,29 @@
|
||||
|
||||
'use strict';
|
||||
|
||||
const React = require('react');
|
||||
const ReactNative = require('react-native');
|
||||
import * as React from 'react';
|
||||
import {useEffect} from 'react';
|
||||
import {NativeModules, StyleSheet, View} from 'react-native';
|
||||
|
||||
const {StyleSheet, View} = ReactNative;
|
||||
const {TestModule} = ReactNative.NativeModules;
|
||||
const {TestModule} = NativeModules;
|
||||
|
||||
class SimpleSnapshotTest extends React.Component<{...}> {
|
||||
componentDidMount(): void {
|
||||
function SimpleSnapshotTest(): React.Node {
|
||||
const done = (success: boolean) => {
|
||||
TestModule.markTestPassed(success);
|
||||
};
|
||||
useEffect(() => {
|
||||
if (!TestModule.verifySnapshot) {
|
||||
throw new Error('TestModule.verifySnapshot not defined.');
|
||||
}
|
||||
requestAnimationFrame(() => TestModule.verifySnapshot(this.done));
|
||||
}
|
||||
requestAnimationFrame(() => TestModule.verifySnapshot(done));
|
||||
}, []);
|
||||
|
||||
done: (success: boolean) => void = (success: boolean) => {
|
||||
TestModule.markTestPassed(success);
|
||||
};
|
||||
|
||||
render(): React.Node {
|
||||
return (
|
||||
<View style={styles.container}>
|
||||
<View style={styles.box1} />
|
||||
<View style={styles.box2} />
|
||||
</View>
|
||||
);
|
||||
}
|
||||
return (
|
||||
<View style={styles.container}>
|
||||
<View style={styles.box1} />
|
||||
<View style={styles.box2} />
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
@@ -57,6 +54,4 @@ const styles = StyleSheet.create({
|
||||
},
|
||||
});
|
||||
|
||||
SimpleSnapshotTest.displayName = 'SimpleSnapshotTest';
|
||||
|
||||
module.exports = SimpleSnapshotTest;
|
||||
export default SimpleSnapshotTest;
|
||||
|
||||
Reference in New Issue
Block a user