AI summary by TwinMind
React's Next Big Change?
Theo - t3․gg
35m 5s
Introduction to React DOM Package
- React DOM is the package that powers React rendering, not the component tree
- React DOM handles actual rendering and DOM insertion
- When using JSX div elements, these are React DOM bindings to browser elements
- React DOM creates bindings for all browser-compatible elements
- React Native uses different approach with limited element set
React Virtual DOM vs Real DOM Structure
- React apps structured as hierarchical nodes (App → TopNav, PageContent)
- React virtual DOM contains component hierarchy and relationships
- Only lowercase HTML elements (main, div) map to real HTML elements
- Uppercase/custom components exist only in React virtual world
- React DOM translates virtual DOM to actual HTML DOM structure
- Create root function from React DOM binds React components to DOM elements
Alternative React Renderers
- React 3 Fiber example: uses Mesh, BoxGeometry, AmbientLight instead of HTML elements
- React Native: imports Text and View components, no traditional HTML elements
- Text must be wrapped in Text component, crashes otherwise
- Styles passed as objects instead of CSS strings
- Different platforms require different rendering approaches
React Native for Web Background
- Started 2015 by Nicholas Gallagher during Twitter Progressive Web App development
- Currently used by Meta, Twitter (now X), and Flipkart in production
- Nicholas moved from Twitter to Meta, now working on React full-time
- Goal: higher level API than raw DOM with predictable styles
- Provides controlled, consistent developer experience
- Limits developer access to specific subset of DOM capabilities
Benefits of Restricted API Approach
- Prevents use of deprecated elements like Marquee
- Ensures accessibility by default through controlled components
- Provides predictable styling behavior vs cascading CSS
- Eliminates CSS cascading issues that affect component reusability
- Better suited for component-based development vs page-based development
- Stylex focus on deterministic resolution and modularity
React Strict DOM Introduction
- New experimental package from Meta combining React DOM and Stylex
- Aims to unify APIs between web and native platforms
- Goal: share maximum code between platforms with fewer engineers
- Subset of React DOM, imperative DOM, and CSS supporting web/native targets
- Currently 4KB vs 70KB+ for React Native Web
- Builds on React DOM for Native proposal with polyfills and new web capabilities
React Strict DOM Implementation Details
- Explicit imports required: HTML elements from react-strict-dom package
- CSS shorthand calls Stylex under the hood
- No longer inferred HTML elements from React DOM installation
- HTML becomes provided component rather than inferred capability
- More verbose but provides greater control over available elements
- Plugin support possible in future for automation
Cross-Platform Element Bindings
- HTML elements mapped to native equivalents
- Article/aside/blockquote → View
- BR/code → Text
- Button → Pressable (animated by default)
- Comprehensive binding system for supported HTML elements
- Creates strict subset compatible across all target platforms
Architecture Comparison
- React Native Web: 70KB+ runtime, polyfills React Native APIs on web
- React Strict DOM: 4KB runtime, polyfills web APIs on React Native
- Separate binding layers for both web and native platforms
- Strict subset approach ensures behavioral consistency
- Focus on good web parts rather than avoiding bad web parts
Event Loop and Synchronization
- Research into unified event loop processing model
- Addresses JavaScript single-thread limitations for rendering
- Ensures correct event ordering across platforms
- Example: Focus event ordering differs between browsers and W3C spec
- Critical for multi-platform consistency (Android, iOS, Windows, Mac, VR, web)
- Enables synchronous layout effects and measurements
DOM Access and Measurement APIs
- Web standard APIs now accessible in React Native
- measureInWindow functionality works consistently across platforms
- Synchronous layout measurements prevent flicker
- Same code runs identically on web and native
- Previously impossible to write reusable platform-interaction code
- Enables proper use of useLayoutEffect across platforms
React Programming Model Fixes
- Addresses React Native issues preventing correct programming model implementation
- useLayoutEffect currently doesn't guarantee pre-repaint execution in React Native
- Can access stale/incorrect layout data
- Goal: reliable multi-pass renders without UI thrash
- Increased alignment with web platform standards
- Enables React Compiler optimizations previously impossible
Production Usage and Future
- Meta currently using React Strict DOM in production
- First cross-platform React solution Meta directly invests in
- Previously built separate components for each platform
- Stage 1 experimental research (equivalent to TC39 Stage 1)
- Not committed deliverable like Server Components
- Open source approach with RFC sharing and community involvement
