Skip to content

Commit

Permalink
Migrate rn-tester/IntegrationTests/ImageSnapshotTest.js to function c…
Browse files Browse the repository at this point in the history
…omponents (facebook#48698)

Summary:

As per title.

Changelog: [Internal]

Reviewed By: rshest

Differential Revision: D68152467
  • Loading branch information
fabriziocucci authored and facebook-github-bot committed Jan 15, 2025
1 parent 7de98f7 commit 9d9ef86
Showing 1 changed file with 17 additions and 20 deletions.
37 changes: 17 additions & 20 deletions packages/rn-tester/IntegrationTests/ImageSnapshotTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,33 +10,30 @@

'use strict';

const React = require('react');
const ReactNative = require('react-native');
const {Image} = ReactNative;
const {TestModule} = ReactNative.NativeModules;
import * as React from 'react';
import {useEffect} from 'react';
import {Image, NativeModules} from 'react-native';

class ImageSnapshotTest extends React.Component<{...}> {
componentDidMount(): void {
const {TestModule} = NativeModules;

function ImageSnapshotTest(): React.Node {
useEffect(() => {
if (!TestModule.verifySnapshot) {
throw new Error('TestModule.verifySnapshot not defined.');
}
}
}, []);

done: (success: boolean) => void = (success: boolean) => {
const done = (success: boolean) => {
TestModule.markTestPassed(success);
};

render(): React.Node {
return (
<Image
source={require('./blue_square.png')}
defaultSource={require('./red_square.png')}
onLoad={() => TestModule.verifySnapshot(this.done)}
/>
);
}
return (
<Image
source={require('./blue_square.png')}
defaultSource={require('./red_square.png')}
onLoad={() => TestModule.verifySnapshot(done)}
/>
);
}

ImageSnapshotTest.displayName = 'ImageSnapshotTest';

module.exports = ImageSnapshotTest;
export default ImageSnapshotTest;

0 comments on commit 9d9ef86

Please sign in to comment.