Skip to content

Commit

Permalink
Fix SnapshotExample
Browse files Browse the repository at this point in the history
Reviewed By: fkgozali

Differential Revision: D5327149

fbshipit-source-id: 685bd2f52b6457b03db2e49df67c9830dd6c102a
  • Loading branch information
sahrens authored and facebook-github-bot committed Jun 27, 2017
1 parent 22ab231 commit 1a5489b
Showing 1 changed file with 12 additions and 16 deletions.
28 changes: 12 additions & 16 deletions RNTester/js/SnapshotExample.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,13 @@
*
* @flow
* @providesModule SnapshotExample
* @format
*/
'use strict';

var React = require('react');
var ReactNative = require('react-native');
var {
Image,
StyleSheet,
Text,
UIManager,
View,
} = ReactNative;
const React = require('react');
const ReactNative = require('react-native');
const {Alert, Image, StyleSheet, Text, View} = ReactNative;

class ScreenshotExample extends React.Component {
state = {
Expand All @@ -32,20 +27,19 @@ class ScreenshotExample extends React.Component {
<Text onPress={this.takeScreenshot} style={style.button}>
Click to take a screenshot
</Text>
<Image style={style.image} source={{uri: this.state.uri}}/>
<Image style={style.image} source={{uri: this.state.uri}} />
</View>
);
}

takeScreenshot = () => {
UIManager
.takeSnapshot('window', {format: 'jpeg', quality: 0.8}) // See UIManager.js for options
.then((uri) => this.setState({uri}))
.catch((error) => alert(error));
ReactNative.takeSnapshot('window', {format: 'jpeg', quality: 0.8}) // See UIManager.js for options
.then(uri => this.setState({uri}))
.catch(error => Alert.alert(error));
};
}

var style = StyleSheet.create({
const style = StyleSheet.create({
button: {
marginBottom: 10,
fontWeight: '500',
Expand All @@ -63,6 +57,8 @@ exports.description = 'API to capture images from the screen.';
exports.examples = [
{
title: 'Take screenshot',
render(): React.Element<any> { return <ScreenshotExample />; }
render(): React.Element<any> {
return <ScreenshotExample />;
},
},
];

0 comments on commit 1a5489b

Please sign in to comment.