Skip to content

fix/enable simple html inline css#902

Merged
s-brankovic merged 2 commits intodevelopfrom
feature/simple-html-inline-css
Feb 24, 2026
Merged

fix/enable simple html inline css#902
s-brankovic merged 2 commits intodevelopfrom
feature/simple-html-inline-css

Conversation

@s-brankovic
Copy link
Copy Markdown
Contributor

@s-brankovic s-brankovic commented Feb 23, 2026

Fix inline CSS styles not being applied (React 19 compatibility)

Problem

Inline style="" attributes in HTML content rendered by SimpleHtml are silently ignored on native devices. This means any HTML with inline styling (colors, text-align, background-color, font-size, etc.) renders without those styles.

Root Cause

react-native-render-html v6.3.4 relies on defaultProps to set default values for its TRenderEngineProvider component, including enableCSSInlineProcessing: true. React 19 (shipped with RN 0.78) completely removed support for defaultProps on function components, causing these defaults to become undefined. When enableCSSInlineProcessing is undefined (falsy), the transient render engine skips all inline style parsing.

Fix

Explicitly pass the three most impactful TRenderEngineProvider defaults in SimpleHtml's htmlProps:

  • enableCSSInlineProcessing: true — required, without this all inline styles are ignored
  • enableUserAgentStyles: true — ensures user-agent styles apply (e.g., <b> renders bold, <em> renders italic)
  • emSize: 14 — ensures em/rem CSS units resolve correctly

The remaining defaults (classesStyles, ignoredDomTags, htmlParserOptions, fallbackFonts) have built-in fallbacks in the library's internal code (buildTREFromConfig.js) and don't require explicit overrides.

Other internal components using defaultProps (TNodeRenderer, TChildrenRenderer, TNodeChildrenRenderer) were verified safe — their compiled code uses optional chaining or JS default parameters, preventing crashes when defaultProps is stripped.

We also considered using the existing patches recommended in the issues bellow , but decided they were an overhaul for our specific use case.

References


@s-brankovic s-brankovic changed the title feature/enable simple html inline css fix/enable simple html inline css Feb 24, 2026
Copy link
Copy Markdown
Contributor

@tomislav-arambasic tomislav-arambasic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GG WP

@s-brankovic s-brankovic merged commit 760811a into develop Feb 24, 2026
@s-brankovic s-brankovic deleted the feature/simple-html-inline-css branch February 24, 2026 10:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants