Skip to content
Merged
Changes from 1 commit
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
5 changes: 5 additions & 0 deletions docs/framework/react/react-native.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,14 @@ import { onlineManager } from '@tanstack/react-query'
import * as Network from 'expo-network'

onlineManager.setEventListener((setOnline) => {
Network.getNetworkStateAsync().then((state) => {
setOnline(!!state.isConnected)
})

const eventSubscription = Network.addNetworkStateListener((state) => {
setOnline(!!state.isConnected)
})

return eventSubscription.remove
Copy link

Copilot AI Feb 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Returning eventSubscription.remove directly may cause a this binding issue when the cleanup function is called. If remove is not bound to eventSubscription, calling it later will result in this being undefined. Consider wrapping it in an arrow function: return () => eventSubscription.remove() to ensure the correct context, similar to the pattern used in examples/react/react-native/src/hooks/useAppState.ts:9.

Suggested change
return eventSubscription.remove
return () => eventSubscription.remove()

Copilot uses AI. Check for mistakes.
})
Comment thread
TkDodo marked this conversation as resolved.
```
Expand Down