Runtime Library
Runtime exports used by the Babel plugin and advanced integrations.
react-native-boost/runtime is used by the Babel plugin to apply optimizations safely across platforms.
Besides re-exporting optimized native components with web-safe fallbacks, it also exposes helper utilities.
Direct usage is supported but generally not recommended unless needed for advanced integrations (for example, Nativewind setup).
API Reference
This section is automatically generated from runtime exports.
Functions
getDefaultTextStyle
The default style Text prepends to every element's style — { overflow: 'hidden' } when defaultTextToOverflowHidden is on (RN ≥ 0.85 default), and undefined otherwise. The plugin prepends this as the first style array entry of every optimized Text, so the user's own overflow still wins; an undefined is ignored by RN's style flattening, so on RN versions without the flag the resolved props are identical to passing no default at all.
- Type:
() => TextStyle | undefined
Returns
TextStyle | undefined
Notes
The flag is read lazily on first use and memoized, mirroring Text.js's render-time read rather
than locking the flag at import: RN's ReactNativeFeatureFlags.override throws once a flag has been
accessed, so a module-load read would break apps that legitimately override flags during startup.
Memoizing cannot diverge from RN — an override after the first Text render throws in stock RN too.
processImageObjectSourceHeaders
Gates a plain OBJECT source's inline headers for the top-level Android headers prop. The plugin wraps the statically-extracted headers in this call so build-time output tracks the installed RN exactly. See {@link liftsObjectSourceHeaders}.
- Type:
(headers: T) => T | undefined
Parameters
headers:T
Returns
T | undefined
processImageArraySourceDimensions
Gates the layout style entry synthesized from a single-entry ARRAY source's intrinsic dimensions. The plugin emits this as the first style array entry so build-time output tracks the installed RN exactly; an undefined entry is ignored by style flattening, exactly like the wrapper's false. See {@link propagatesArraySourceDimensions}.
- Type:
(dimensions: T) => T | undefined
Parameters
dimensions:T
Returns
T | undefined
processTextStyle
Normalizes Text style values for NativeText.
- Type:
(style: GenericStyleProp<TextStyle>) => Partial<TextProps>
Parameters
style:GenericStyleProp<TextStyle>- Style prop passed to a text-like component.
Returns
Partial<TextProps>: Native-friendly text props. Returns an empty object when style is falsy or cannot be normalized.
Notes
- Flattens style arrays via StyleSheet.flatten
* - Converts numeric fontWeight values to string values
* - Maps userSelect and verticalAlign to native-compatible props
* - Prepends {@link getDefaultTextStyle}so the flag-gated overflow: 'hidden' default applies to
* dynamically-styled (and falsy-styled) Text exactly as the wrapper applies it
processSelectionColor
Mirrors the selectionColor normalization Text performs before handing off to its native host: selectionColor != null ? processColor(selectionColor) : undefined (Text.js). Returns a spreadable prop bag so the plugin can inline it at the JSX call site like {@link processTextStyle}.
- Type:
(selectionColor: number | ColorValue | null | undefined) => { selectionColor?: ColorValue | ProcessedColorValue | null; }
Parameters
selectionColor:number | ColorValue | null | undefined- The rawselectionColorprop (CSS color string, int, orPlatformColor).
Returns
{ selectionColor?: ColorValue | ProcessedColorValue | null; }: { selectionColor } with the processed value, or an empty object when nothing should be
emitted: a null/undefined input collapses to {}, and a value processColor rejects (returns
undefined, e.g. an unparseable color string) is likewise omitted, mirroring Text's
if (_selectionColor !== undefined) guard. A null from processColor (a rejected PlatformColor)
is preserved, since Text forwards that.
Notes
No caching: keys are commonly primitives ('red', 0xff0000ff) that a WeakMap rejects, and
processColor is already cheap. When processColor is unavailable (a non-RN host) the raw value is
passed through rather than dropped, the least-surprising degradation.
processImageSourceProps
Normalizes dynamic Image source/style props for NativeImage.
- Type:
(props: ImageSourceHelperProps) => Record<string, any>
Parameters
props:ImageSourceHelperProps
Returns
Record<string, any>
Notes
Static Image cases are still rewritten at build time. This helper is only emitted when the source
or style cannot be safely flattened by Babel, so it mirrors the RN wrapper's runtime work:
resolveAssetSource, src/request-header synthesis, object-vs-array source style construction,
objectFit/resizeMode, and iOS tint fallback.
processTextAccessibilityProps
Normalizes accessibility and ARIA props for runtime native components, mirroring the reconciliation Text performs before handing off to its native host.
- Type:
(props: Record<string, any>) => Record<string, any>
Parameters
props:Record<string, any>- Accessibility and ARIA props.
Returns
Record<string, any>: Props with normalized accessibility fields.
Notes
- Merges aria-label with accessibilityLabel
* - Merges ARIA state fields into accessibilityState
* - Reconciles disabled with accessibilityState.disabled (the explicit disabled prop wins)
* - Translates aria-hidden into accessibilityElementsHidden / importantForAccessibility (see
* {@link applyAriaHidden}); aria-hidden wins over an explicitly-passed value
* - Resolves the platform-specific accessible default (see {@link getDefaultTextAccessible})
processViewAccessibilityProps
Normalizes accessibility and ARIA props for an optimized NativeView, mirroring the reconciliation the View wrapper performs before handing off to its native host.
- Type:
(props: Record<string, any>) => Record<string, any>
Parameters
props:Record<string, any>- Accessibility and ARIA props.
Returns
Record<string, any>: Props with the ARIA cluster translated/aggregated into their native counterparts.
Notes
Unlike {@link processTextAccessibilityProps}(the Text helper) there is no accessible default and no
* disabled reconciliation — the View wrapper does neither. A static tabIndex is folded to
* focusable at build time; only a dynamic tabIndex reaches this helper.
* - aria-labelledby → accessibilityLabelledBy (comma-split into a string array)
* - aria-label → accessibilityLabel
* - aria-live → accessibilityLiveRegion ('off' → 'none')
* - aria-hidden → accessibilityElementsHidden (+ importantForAccessibility when strictly true)
* - tabIndex → focusable (!tabIndex)
* - ARIA state fields aggregated into accessibilityState (ariaX ?? accessibilityState?.x)
* - ARIA value fields aggregated into accessibilityValue (ariaX ?? accessibilityValue?.x)
processImageAccessibilityProps
Normalizes the Image wrapper's accessibility aliases before props reach NativeImage.
- Type:
(props: Record<string, any>) => Record<string, any>
Parameters
props:Record<string, any>
Returns
Record<string, any>
Notes
Image's rules are close to View's ARIA merge, but not identical: alt is an accessibilityLabel
fallback and also forces accessible on. Keep this separate from processViewAccessibilityProps
so those Image-only precedence rules stay explicit.
Components
NativeText
Native Text component with graceful fallback.
- Type:
ComponentType<TextProps>
Notes
Uses unstable_NativeText on supported native runtimes and falls back to Text
on web or when the unstable export is unavailable.
NativeView
Native View component with graceful fallback.
- Type:
ComponentType<ViewProps>
Notes
Uses unstable_NativeView on supported native runtimes and falls back to View
on web or when the unstable export is unavailable.
NativeImage
Native Image component with graceful fallback.
- Type:
ComponentType<ImageProps>
Notes
React Native does not expose an unstable_NativeImage, so this uses the internal host when
available and falls back to Image.
Constants
getDefaultTextAccessible
The default value Text resolves for accessible when the prop is omitted: true on iOS (text is an accessibility element unless opted out), false on Android, and undefined elsewhere.
- Type:
() => boolean | undefined
Notes
Runtime fallback for the common optimized <Text> path (no accessibility props) when the target
platform is unknown at build time. When it is known (Metro reports it on the Babel caller), the
plugin inlines the literal instead and this is not emitted. Evaluated per render — like Text's own
Platform.select — rather than hoisted to a constant, so it always reflects the current platform.
userSelectToSelectableMap
Maps CSS-like userSelect values to React Native's selectable prop.
- Type:
{ auto: boolean; text: boolean; none: boolean; contain: boolean; all: boolean; }
verticalAlignToTextAlignVerticalMap
Maps CSS-like verticalAlign values to React Native's textAlignVertical.
- Type:
{ auto: string; top: string; bottom: string; middle: string; }
clampNumberOfLines
Clamps a numberOfLines value exactly as Text does at runtime: a negative number (or NaN) becomes 0, while null/undefined pass through untouched (!(value >= 0) is true for negatives and NaN, false otherwise). The plugin emits this only around a non-literal numberOfLines; literal negatives are clamped at build time, so it never runs for them.
- Type:
(value: number | null | undefined) => number | null | undefined
Types
GenericStyleProp
Recursive style prop shape accepted by runtime style helpers.
- Type:
null | void | T | false | '' | ReadonlyArray<GenericStyleProp<T>>
Additional Tags
- @template: - Style object type.