Moving Towards a Stable JavaScript API in React Native
Article Summary
React Native 0.80 is making a bold move: deprecating deep imports and introducing auto-generated TypeScript types. This is the foundation for a truly stable API.
The React Native team at Meta is tackling a long-standing problem with their JavaScript API. Historically, types were manually maintained by the community and internal imports were accessible but unstable. Now they're drawing clear boundaries around what's public and what's private.
Key Takeaways
- Deep imports like 'react-native/Libraries/Alert/Alert' now trigger deprecation warnings
- New Strict TypeScript API generates types directly from Flow source code
- Opt-in via tsconfig.json with 'react-native-strict-api' custom condition
- Types now locked to index.js exports, preventing internal changes from breaking apps
- Removal of deep imports targeted for version 0.82
Critical Insight
React Native is finally defining a stable public API by deprecating deep imports and offering auto-generated TypeScript types that guarantee accuracy with the source code.