Skip to content

Commit 1f3d7c3

Browse files
hyochanclaude
andcommitted
docs: remove non-existent connectionError from useIAP examples
The connectionError property does not exist in the useIAP hook. Updated documentation to use the correct API: connected state and onPurchaseError callback for handling connection errors. Closes #304 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 855463b commit 1f3d7c3

File tree

5 files changed

+90
-40
lines changed

5 files changed

+90
-40
lines changed

docs/docs/guides/troubleshooting.md

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -295,20 +295,26 @@ const checkDeviceSupport = async () => {
295295

296296
#### 1. Network connectivity
297297

298-
Handle network errors gracefully:
298+
Handle connection errors gracefully using the `connected` state and `onPurchaseError` callback:
299299

300300
```tsx
301-
const {connectionError} = useIAP();
301+
const {connected} = useIAP({
302+
onPurchaseError: (error) => {
303+
if (error.code === ErrorCode.NetworkError) {
304+
// Handle network error
305+
Alert.alert('Network Error', 'Please check your internet connection.');
306+
}
307+
},
308+
});
302309
303-
if (connectionError) {
310+
if (!connected) {
304311
return (
305312
<View>
306313
<Text>Store connection failed</Text>
307-
<Text>{connectionError.message}</Text>
308314
<Button
309315
title="Retry"
310316
onPress={() => {
311-
// Implement retry logic
317+
// Implement retry logic (e.g., remount the component)
312318
retryConnection();
313319
}}
314320
/>
@@ -410,11 +416,15 @@ const {} = useIAP({
410416
### 3. Monitor connection state
411417

412418
```tsx
413-
const {connected, connectionError} = useIAP();
419+
const {connected} = useIAP({
420+
onPurchaseError: (error) => {
421+
console.log('Purchase error:', error);
422+
},
423+
});
414424
415425
useEffect(() => {
416-
console.log('Connection state changed:', {connected, error: connectionError});
417-
}, [connected, connectionError]);
426+
console.log('Connection state changed:', connected);
427+
}, [connected]);
418428
```
419429

420430
## Testing Strategies

docs/versioned_docs/version-3.0/guides/troubleshooting.md

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -293,20 +293,26 @@ const checkDeviceSupport = async () => {
293293

294294
#### 1. Network connectivity
295295

296-
Handle network errors gracefully:
296+
Handle connection errors gracefully using the `connected` state and `onPurchaseError` callback:
297297

298298
```tsx
299-
const {connectionError} = useIAP();
299+
const {connected} = useIAP({
300+
onPurchaseError: (error) => {
301+
if (error.code === ErrorCode.NetworkError) {
302+
// Handle network error
303+
Alert.alert('Network Error', 'Please check your internet connection.');
304+
}
305+
},
306+
});
300307
301-
if (connectionError) {
308+
if (!connected) {
302309
return (
303310
<View>
304311
<Text>Store connection failed</Text>
305-
<Text>{connectionError.message}</Text>
306312
<Button
307313
title="Retry"
308314
onPress={() => {
309-
// Implement retry logic
315+
// Implement retry logic (e.g., remount the component)
310316
retryConnection();
311317
}}
312318
/>
@@ -414,11 +420,15 @@ useEffect(() => {
414420
### 3. Monitor connection state
415421

416422
```tsx
417-
const {connected, connectionError} = useIAP();
423+
const {connected} = useIAP({
424+
onPurchaseError: (error) => {
425+
console.log('Purchase error:', error);
426+
},
427+
});
418428
419429
useEffect(() => {
420-
console.log('Connection state changed:', {connected, error: connectionError});
421-
}, [connected, connectionError]);
430+
console.log('Connection state changed:', connected);
431+
}, [connected]);
422432
```
423433

424434
## Testing Strategies

docs/versioned_docs/version-3.1/guides/troubleshooting.md

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -290,20 +290,26 @@ const checkDeviceSupport = async () => {
290290

291291
#### 1. Network connectivity
292292

293-
Handle network errors gracefully:
293+
Handle connection errors gracefully using the `connected` state and `onPurchaseError` callback:
294294

295295
```tsx
296-
const {connectionError} = useIAP();
296+
const {connected} = useIAP({
297+
onPurchaseError: (error) => {
298+
if (error.code === ErrorCode.NetworkError) {
299+
// Handle network error
300+
Alert.alert('Network Error', 'Please check your internet connection.');
301+
}
302+
},
303+
});
297304
298-
if (connectionError) {
305+
if (!connected) {
299306
return (
300307
<View>
301308
<Text>Store connection failed</Text>
302-
<Text>{connectionError.message}</Text>
303309
<Button
304310
title="Retry"
305311
onPress={() => {
306-
// Implement retry logic
312+
// Implement retry logic (e.g., remount the component)
307313
retryConnection();
308314
}}
309315
/>
@@ -405,11 +411,15 @@ const {} = useIAP({
405411
### 3. Monitor connection state
406412

407413
```tsx
408-
const {connected, connectionError} = useIAP();
414+
const {connected} = useIAP({
415+
onPurchaseError: (error) => {
416+
console.log('Purchase error:', error);
417+
},
418+
});
409419
410420
useEffect(() => {
411-
console.log('Connection state changed:', {connected, error: connectionError});
412-
}, [connected, connectionError]);
421+
console.log('Connection state changed:', connected);
422+
}, [connected]);
413423
```
414424

415425
## Testing Strategies

docs/versioned_docs/version-3.2/guides/troubleshooting.md

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -290,20 +290,26 @@ const checkDeviceSupport = async () => {
290290

291291
#### 1. Network connectivity
292292

293-
Handle network errors gracefully:
293+
Handle connection errors gracefully using the `connected` state and `onPurchaseError` callback:
294294

295295
```tsx
296-
const {connectionError} = useIAP();
296+
const {connected} = useIAP({
297+
onPurchaseError: (error) => {
298+
if (error.code === ErrorCode.NetworkError) {
299+
// Handle network error
300+
Alert.alert('Network Error', 'Please check your internet connection.');
301+
}
302+
},
303+
});
297304
298-
if (connectionError) {
305+
if (!connected) {
299306
return (
300307
<View>
301308
<Text>Store connection failed</Text>
302-
<Text>{connectionError.message}</Text>
303309
<Button
304310
title="Retry"
305311
onPress={() => {
306-
// Implement retry logic
312+
// Implement retry logic (e.g., remount the component)
307313
retryConnection();
308314
}}
309315
/>
@@ -405,11 +411,15 @@ const {} = useIAP({
405411
### 3. Monitor connection state
406412

407413
```tsx
408-
const {connected, connectionError} = useIAP();
414+
const {connected} = useIAP({
415+
onPurchaseError: (error) => {
416+
console.log('Purchase error:', error);
417+
},
418+
});
409419
410420
useEffect(() => {
411-
console.log('Connection state changed:', {connected, error: connectionError});
412-
}, [connected, connectionError]);
421+
console.log('Connection state changed:', connected);
422+
}, [connected]);
413423
```
414424

415425
## Testing Strategies

docs/versioned_docs/version-3.3/guides/troubleshooting.md

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -290,20 +290,26 @@ const checkDeviceSupport = async () => {
290290

291291
#### 1. Network connectivity
292292

293-
Handle network errors gracefully:
293+
Handle connection errors gracefully using the `connected` state and `onPurchaseError` callback:
294294

295295
```tsx
296-
const {connectionError} = useIAP();
296+
const {connected} = useIAP({
297+
onPurchaseError: (error) => {
298+
if (error.code === ErrorCode.NetworkError) {
299+
// Handle network error
300+
Alert.alert('Network Error', 'Please check your internet connection.');
301+
}
302+
},
303+
});
297304
298-
if (connectionError) {
305+
if (!connected) {
299306
return (
300307
<View>
301308
<Text>Store connection failed</Text>
302-
<Text>{connectionError.message}</Text>
303309
<Button
304310
title="Retry"
305311
onPress={() => {
306-
// Implement retry logic
312+
// Implement retry logic (e.g., remount the component)
307313
retryConnection();
308314
}}
309315
/>
@@ -405,11 +411,15 @@ const {} = useIAP({
405411
### 3. Monitor connection state
406412

407413
```tsx
408-
const {connected, connectionError} = useIAP();
414+
const {connected} = useIAP({
415+
onPurchaseError: (error) => {
416+
console.log('Purchase error:', error);
417+
},
418+
});
409419
410420
useEffect(() => {
411-
console.log('Connection state changed:', {connected, error: connectionError});
412-
}, [connected, connectionError]);
421+
console.log('Connection state changed:', connected);
422+
}, [connected]);
413423
```
414424

415425
## Testing Strategies

0 commit comments

Comments
 (0)