Skip to content

Commit c5b3ba8

Browse files
authored
Merge pull request #10326 from Expensify/ionatan_onyxdev
Expose Onyx in web development
2 parents e57e113 + 6c4f97c commit c5b3ba8

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,10 @@ Our React Native Android app now uses the `Hermes` JS engine which requires your
121121
3. You should now see a "Hermes React Native" target with an "inspect" link which can be used to bring up a debugger. If you don't see the "inspect" link, make sure the Metro server is running.
122122
4. You can now use the Chrome debug tools. See [React Native Debugging Hermes](https://reactnative.dev/docs/hermes#debugging-hermes-using-google-chromes-devtools)
123123

124+
## Web
125+
126+
To make it easier to test things in web, we expose the Onyx object to the window, so you can easily do `Onyx.set('bla', 1)`.
127+
124128
---
125129

126130
# App Structure and Conventions

src/App.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import React from 'react';
33
import {LogBox} from 'react-native';
44
import {GestureHandlerRootView} from 'react-native-gesture-handler';
55
import {SafeAreaProvider} from 'react-native-safe-area-context';
6+
import Onyx from 'react-native-onyx';
67
import CustomStatusBar from './components/CustomStatusBar';
78
import ErrorBoundary from './components/ErrorBoundary';
89
import Expensify from './Expensify';
@@ -11,6 +12,12 @@ import OnyxProvider from './components/OnyxProvider';
1112
import HTMLEngineProvider from './components/HTMLEngineProvider';
1213
import ComposeProviders from './components/ComposeProviders';
1314
import SafeArea from './components/SafeArea';
15+
import * as Environment from './libs/Environment/Environment';
16+
17+
// For easier debugging and development, when we are in web we expose Onyx to the window, so you can more easily set data into Onyx
18+
if (window && Environment.isDevelopment()) {
19+
window.Onyx = Onyx;
20+
}
1421

1522
LogBox.ignoreLogs([
1623
// Basically it means that if the app goes in the background and back to foreground on Android,

0 commit comments

Comments
 (0)