Xiong describes how a monorepo can help teams share components across multiple mobile apps, business logic between React Native and web apps, and types between frontend and backend code. She defines a monorepo as one repository containing distinct projects with clear relationships. Nx provides generators and defaults for testing, linting, and end-to-end testing, plus a dependency graph and computation caching.
How to use React Native with Nx in monorepo
Speaker
Emily Xiong, a developer at Nrwl.io, explains how to use Nx to manage React Native apps and shared code in a monorepo at React Native EU 2022.
Xiong creates an Nx workspace with a React Native app, then adds a second app and a shared UI components library. She generates a button component in the library and imports it into both apps. The dependency graph then shows each app depending on the shared library.
Xiong uses a Studio Ghibli search app to demonstrate a React Native mobile app and a React web app sharing state management, API services, models, interfaces, and types. She shows how to launch the mobile app in a simulator and serve the web app in a browser.
Nx sets up unit testing with React Native Testing Library, and generated components include spec files. Xiong runs tests with `nx test` and describes `--watch` for rerunning them after changes. For end-to-end testing, she uses Detox with Jest to follow a Totoro search from the input through results to the My Neighbor Totoro detail page.
Xiong describes Storybook as a tool for developing, testing, and documenting presentational components with mock data. She shows how to generate a React Native Storybook configuration, launch it alongside the app, and open a film card story with sample data.
Takeaways
- Use a monorepo when multiple apps need to share components, business logic, or types.
- Use Nx generators to scaffold React Native apps, libraries, tests, and Storybook configuration.
- Check the dependency graph to understand which apps use each shared library.
- Use computation caching to reuse results for unchanged builds, tests, and linting tasks.
- Keep component stories focused on presentational UI and supply them with mock data.
Mentioned in this talk
Search inside this talk
What was claimed 10
- role atEmily Xiong is developer for the React Native and Expo libraries at Nrwl.io
“I’m a developer for the React Native and now Expo libraries.”
YouTube Unverified1 source· Talk
- built
“Our company has an open-source software called Nx.”
YouTube Unverified1 source· Talk
- works atEmily Xiong works at Nrwl.io
“I work for a company called Nrwl.io.”
YouTube Unverified1 source· Talk
- featureNx: Dependency graph shows relationships between applications and libraries
“It’s an interactive tool that lets you see the relationships between all your applications and libraries.”
YouTube Unverified1 source· Talk
- featureNx: Computation caching retrieves task results when code has not changed
“if you make no changes to your library or application, you will retrieve the build from the cache”
YouTube Unverified1 source· Talk
- usesNx uses React Native
“I'm going to create it with React Native.”
YouTube Unverified1 source· Talk
- uses
“We’re going to use Testing Library for React Native.”
YouTube Unverified1 source· Talk
- integrates with
“It's similar to Cypress for web applications.”
YouTube Unverified1 source· Talk





