Metro (React Native, Expo)
npm install --save-dev @hozo/metro @hozo/compilernpm install @hozo/core// metro.config.jsconst { getDefaultConfig } = require('@react-native/metro-config')const { withHozo } = require('@hozo/metro/config')// Exported as a promise, which Metro awaits: the project-wide candidate// module has to be generated before the bundle starts.module.exports = withHozo(getDefaultConfig(__dirname), { css: 'src/theme.css' })Expo’s starter has no metro.config.js. Expo uses its own default
until a project writes one, so create it, starting from Expo’s default
rather than React Native’s:
// metro.config.jsconst { getDefaultConfig } = require('expo/metro-config')const { withHozo } = require('@hozo/metro/config')module.exports = withHozo(getDefaultConfig(__dirname), { css: 'src/theme.css' })The React Native CLI’s starter exports
mergeConfig(getDefaultConfig(__dirname), config); wrap that expression in
withHozo(…) the same way.
On React Native 0.87, pin androidx.collection on Android. This is not
Hozo’s bug, but any app on 0.87 can hit it. React Native 0.87 keeps Android’s
view registry in androidx.collection’s MutableIntObjectMap, and the 1.4.0–1.4.2
versions it resolves can lose entries after a run of removals. Views that were
never deleted then stop receiving updates: text stays stale, buttons stop
responding, and logcat says Unable to find viewState for tag N.
examples/native-demo hit this in about half its runs until it pinned the fix:
// android/app/build.gradledependencies { implementation("androidx.collection:collection:1.4.4")}React Native 0.88 ships 1.4.4 (reactwg/react-native-releases#1426), so the pin is for 0.87 only.