# @monarcode/effetch-query/react-native (https://effetch-query.monarcode.dev/docs/reference/react-native)

`@monarcode/effetch-query/react-native` builds a client's signals from React Native's own modules, which you pass in. Import what you use:

```ts
import { reactNativeSignals } from "@monarcode/effetch-query/react-native";
```

Its exports follow, grouped by the guide that covers them, each with its
docs. Your editor shows the same docs, with an example, when you hover the
name.

## React Native

Guide: [React Native](https://effetch-query.monarcode.dev/docs/react/react-native).

### reactNativeSignals

Makes signals for React Native: focus is the app coming back to the foreground (`AppState` changing to `"active"` from anything else), and online follows NetInfo's `isConnected`, where `null` (not known yet) counts as online. Pass them as the `signals` option of `QueryClient.make`, in place of the default [`Signals.browser`](https://effetch-query.monarcode.dev/docs/reference/signals#browser), which never changes without a DOM. The parameters are [`AppStateLike`](https://effetch-query.monarcode.dev/docs/reference/react-native#appstatelike) and [`NetInfoLike`](https://effetch-query.monarcode.dev/docs/reference/react-native#netinfolike).

Each client starts its own listeners when one of its queries first needs them, and stops them once no cached query does or the client is disposed, so one set of signals can serve several clients.

### AppStateLike

The part of React Native's `AppState` that [`reactNativeSignals`](https://effetch-query.monarcode.dev/docs/reference/react-native#reactnativesignals) uses. `AppState` from `react-native` satisfies it, so this package never imports `react-native`.

| Prop               | Type       | Description                                                                                    |
| ------------------ | ---------- | ---------------------------------------------------------------------------------------------- |
| `currentState`     | `union`    | The app's state now: `"active"` when it's in the foreground.                                   |
| `addEventListener` | `function` | Listens for changes to the app's state; returns a subscription whose `remove` stops listening. |

### NetInfoLike

The part of NetInfo (`@react-native-community/netinfo`) that [`reactNativeSignals`](https://effetch-query.monarcode.dev/docs/reference/react-native#reactnativesignals) uses. Its default export satisfies it, so this package never imports it.

| Prop               | Type       | Description                                                                                                                   |
| ------------------ | ---------- | ----------------------------------------------------------------------------------------------------------------------------- |
| `addEventListener` | `function` | Listens for network changes; returns a function that stops listening. `isConnected` is `null` while NetInfo doesn't know yet. |

### ReactNativeSignalsOptions

What [`reactNativeSignals`](https://effetch-query.monarcode.dev/docs/reference/react-native#reactnativesignals) listens to.

| Prop       | Type     | Description                |
| ---------- | -------- | -------------------------- |
| `AppState` | `object` | React Native's `AppState`. |
| `NetInfo`  | `object` | NetInfo's default export.  |