Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

prevent call methods being not initialized #228

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -364,17 +364,13 @@ function App() {
Stripe Terminal SDK provides dedicated hook which exposes bunch of methods and props to be used within your App.
Additionally, you have access to the internal state of SDK that contains information about the current connection, discovered readers and loading state.

Alternatively, you can import all of the functions directly from the module but keep in mind that you will lose the access to SDK state.

```tsx
// Screen.ts

import { useStripeTerminal } from '@stripe/stripe-terminal-react-native';

// Alternatively you can import the methods directly.
import {
useStripeTerminal,
discoverReaders,
} from '@stripe/stripe-terminal-react-native';

export default function PaymentScreen() {
Expand Down
7 changes: 6 additions & 1 deletion example/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,14 @@ export default function App() {
const { initialize: initStripe } = useStripeTerminal();

const handlePermissionsSuccess = useCallback(async () => {
const { error } = await initStripe();
const { error, reader } = await initStripe();
if (error) {
Alert.alert('StripeTerminal init failed', error.message);
} else if (reader) {
console.log(
'StripeTerminal has been initialized properly and connected to the reader',
reader
);
} else {
console.log('StripeTerminal has been initialized properly');
}
Expand Down
Loading