Skip to content

Instantly share code, notes, and snippets.

@callstack-bot
Last active November 2, 2022 09:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save callstack-bot/c4a926e875fe4053fd007a6f7cc38d5b to your computer and use it in GitHub Desktop.
Save callstack-bot/c4a926e875fe4053fd007a6f7cc38d5b to your computer and use it in GitHub Desktop.
import React from "react";
import { View, Button, Text } from "react-native";
import { presentIdentityVerificationSheet } from "@stripe/stripe-identity-react-native";
const fetchVerificationSessionParams = async () => {
// same implementation as in function component
};
const fetchOptions = async () => {
// same implementation as in function component
};
class VerifyScreen extends React.Component {
constructor(props) {
super(props);
this.state = { loading: false, status: undefined, error: undefined };
}
present = async () => {
// without provided hooks implementation user has to manage error and loading states manually
this.setState({ loading: true });
const options = await fetchOptions();
this.setState({ loading: false });
const { status, error } = await presentIdentityVerificationSheet(options);
this.setState({ status, error });
};
render() {
return (
<View>
<View>
{this.state.loading ? (
<View>
<Text>Loading...</Text>
</View>
) : (
<Button title="Verify Identity" onPress={this.present} />
)}
</View>
<Text>Status: {this.state.status}</Text>
</View>
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment