-
-
Save callstack-bot/c4a926e875fe4053fd007a6f7cc38d5b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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