Example application to demonstrate how to use react-native-onyx.
| iOS | Android |
|---|---|
![]() |
![]() |
- Install dependencies:
npm install && cd ios && pod install && cd .. - Start the simulator, metro, and boot the app:
npm run ios
- Install dependencies:
npm install - Start the emulator, metro, and boot the app:
npm run android
- Onyx persists data to disk
- This is made clear by the difference in
<StateCounter />vs<OnyxCounter />when you kill the app - State is only kept in memory, Onyx saves data to the disk (via
AsyncStorage)
- This is made clear by the difference in
- UI binds to data via state/props
- Onyx has a higher-order component (HOC) named
withOnyxthat binds the UI to changes in Onyx. When the data changes in Onyx, the component will re-render these changes.
- Onyx has a higher-order component (HOC) named
- When should you use
withOnyxHOC orOnyx.connect?- React components should use
withOnyx() - Non-React libraries should use
Onyx.connect()
- React components should use
- Different Onyx methods
set()- SeeclearNumberFacts()merge()- SeegetAndSaveNumberFact()mergeCollection()- seemergeCatAndDogFacts()

