-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAcceleratedCheckoutStates.jsx
More file actions
37 lines (33 loc) · 1.01 KB
/
AcceleratedCheckoutStates.jsx
File metadata and controls
37 lines (33 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
// [START accelerated-checkouts.states]
import React, { useState } from 'react';
import { ActivityIndicator, Text, View, StyleSheet } from 'react-native';
import {
AcceleratedCheckoutButtons,
RenderState,
} from '@shopify/checkout-sheet-kit';
function CheckoutButtons() {
const [renderState, setRenderState] = useState(RenderState.Loading);
return (
<View>
{renderState === RenderState.Loading && (
<View style={styles.placeholder}>
<ActivityIndicator />
</View>
)}
{renderState === RenderState.Error && (
<View style={styles.placeholder}>
<Text>Couldn't load checkout. Please try again.</Text>
</View>
)}
<AcceleratedCheckoutButtons
cartId="gid://shopify/Cart/123"
onRenderStateChange={(event) => setRenderState(event.state)}
/>
</View>
);
}
const styles = StyleSheet.create({
placeholder: { padding: 16, alignItems: 'center' },
});
export default CheckoutButtons;
// [END accelerated-checkouts.states]