Skip to content
Open
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
85 changes: 85 additions & 0 deletions docs/quick-start/expo-web-and-native.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
---
id: expo-web-and-native
title: Expo Web and Native
---

# Quick Start for Expo targeting Web and Native

To run Reactotron in an Expo app where you target both web and native platforms, you need to combine the "react-js" and "react-native" setup, and leverage the platform file extensions to load the right config for the current platform.

If you are only targeting native platforms, or only targeting the web platform, you can use the [react-native](./react-native.md) or [react-js](./react-js.md) guides respectively.

## Installing Reactotron.app

Let’s [download the desktop app](https://github.com/infinitered/reactotron/releases?q=reactotron-app&expanded=true) to start. You can download for Linux, Windows, and Mac.

Unzip & run.

![Installing The App](./images/react-js/installing.jpg)

## Configure Reactotron with your project

#### **Step 1 - Add Reactotron as DEV dependency**

Add Reactotron, in both react-native and react-js flavors, in your Expo project as a dev dependency.

```
npm i --save-dev reactotron-react-native reactotron-react-js
```

```
yarn add reactotron-react-native reactotron-react-js -D
```

#### **Step 2 - Initialization**

Create a file in your root folder `ReactotronConfig.native.js` and paste this:

```js
import Reactotron from "reactotron-react-native";

Reactotron.configure() // controls connection & communication settings
.useReactNative() // add all built-in react native plugins
.connect(); // let's connect!
```

See the [react-native page](./react-native.md) if you want to customize Reactotron for React-native further.

Then create another file in your root folder named `ReactotronConfig.web.js` and paste this:

```js
import Reactotron from "reactotron-react-js"

Reactotron.configure() // we can use plugins here
.connect() // let's connect!
```

#### **Step 3 - Add Reactotron to your app**

Finally, we import the configuration in the `app/_layout.js` file which is the lowest-level file that Expo Router gives us access to.

After the imports:

```js
if (__DEV__) {
require("../ReactotronConfig"); // Or "../../ReactotronConfig" if you use a /src folder.
}
```

Expo will load either the native or the web flavor of ReactotronConfig based on the platform it is running in. At this point, Reactotron is hooked up. **HOUSTON, WE HAVE A CONNECTION!**

Refresh your app (or start it up with `expo start`) and have a look at Reactotron now. Do you see the `CONNECTION` line? Click that to expand.

![We Have Contact](./images/react-native/first-connect.jpg)

Go back to your app and refresh it 5 or 6 times. Now look.

![Chatty](./images/react-native/spammy.jpg)

## Troubleshooting

**Android**: If you are using an Android device or an emulator run the following command to make sure it can connect to Reactotron:

```
adb reverse tcp:9090 tcp:9090
```
2 changes: 2 additions & 0 deletions docs/quick-start/react-native.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ title: react-native

# Quick Start for React Native

If you are using Expo *and* targeting *both* the native and web platforms, follow the [expo-web-and-native](./expo-web-and-native.md) guide instead.

## Installing Reactotron.app

Let’s [download the desktop app](https://github.com/infinitered/reactotron/releases?q=reactotron-app&expanded=true) to start. You can download for Linux, Windows, and Mac.
Expand Down
6 changes: 6 additions & 0 deletions docs/troubleshooting.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,9 @@ and reload the app on your device.
This only works on Android 5.x+.

As of 1.1.4, the proper IP address is auto-discovered. Simply leave the `configure` as is.

## Web

If you are using Expo and open your app in a browser, having only integrated Reactotron for the native side, you will see some confusing errors.

In this case you need to integrate Reactotron for *both* web and native by following this guide: [expo-web-and-native](./quick-start/expo-web-and-native.md)