Repository - API - Source
source.uri
failing to cause HTML to loadallowWhitespaceNodes
prop to avoid removal of whitespace-filled text nodesbaseFontStyle
updates (port from dev/4.x branch)onParsed
, alterData
, alterChildren
(thanks @SPWizard01)source
prop which deprecates html
and uri
props. This prop
supports method
, body
and headers
fields :rocket:HTMLImage
component which should be much better at adapting its
size to available width. For this to happen, you must pass contentWidth
prop. We recommend using useWindowDimensions().width
to handle screen
rotation gracefully. If you don't want your images to grow after a certain
size, you could use computeEmbeddedMaxWidth
. Read the RFC document “A
Deterministic Approach to Embedded Content
Scaling”
for more details.computeEmbeddedMaxWidth
(see usage above).contentWidth
(see usage above).htmlParserOptions
to override
htmlparser2
ParserOptions object, thanks @fabianlee1211.onLinkPress
has now a default value: open links with Linking
API
(recommended).WebView
optional prop for plugins which requires it, see
@native-html/plugins, thanks
@IjzerenHeindefaultTextProps
, thanks @Peretz30defaultWebViewProps
for WebView
-based plugins (tables, iframes...).constructStyles
, getParentsTagsRecursively
,
getClosestNodeParentByTag
and IGNORED_TAGS
from index.js.domNode
field in passProps
.domNodeToHTMLString
util to get the HTML representation of a DOM node.TransientNode
) as well as onParsed
.img
's tag resizeMode
property not modifiable through tagStyles
, #172;imagesMaxWidth
not working, #412allowFontScaling
, use defaultTextProps.allowFontScaling
instead;textSelectable
, use defaultTextProps.selectable
instead;decodeEntities
, use htmlParserOptions.decodeEntities
instead.html
, use source.html
instead.uri
, use source.uri
instead.iframe
tag element is not rendered anymore, and react-native-webview
has
been removed from peer dependencies; use
@native-html/iframe-plugin
instead, which supports onLinkPress
and scales to content width :rocket:.imagesMaxWidth
and staticContentMaxWidth
have been discontinued in favor
of computeEmbeddedMaxWidth
. This function takes the provided contentWidth
as 1st argument, tag name as 2d argument and returns the max width of the
embedded (iframe, image...).passProps
4th argument of renderer functions, the field
rawChildren
has been renamed to transientChildren
.HTML
component on baseFontStyle
updatessrc
attributes starting with "//" in img
and iframe
elements are not rendered (#408)HTML
: use a proxy method setStateSafe
to avoid updating while unmounted.textSelectable
not working for tagName textwrapper
(#193), thanks @brsaylor2acronym
tag, thanks Brainyoo⚠️ react-native-webview
is now a peer dependency. As a result, you need to install it yourself. Please follow the plugin's instructions.
<iframe>
tag (thanks @Ryabchikus)baseFontSize
for <a>
tags⚠️ As of this release, react-native-render-html
is now compatible with RN < 0.58 once again. Feel free to upgrade from 3.10.0
to 4.1.1
regardless of your RN version. ⚠️
style="calc(100% - 20px);"
normal
and unset
keys<pre>
. This lets you display preformatted text such as code inside your content with a monospace font. #196allowFontScaling
prop. #157 (thanks @amhinson !)srcdoc
in <iframe>
tags. #148 (thanks @charpeni !)<ul>
inside <ol>
#173 (thanks @muhamad-rizki)HTMLImage
's state after it's been unmounted. This prevents warnings during development. 4fca299<pre>
tags #196 (thanks @henry40408 !)stream
dependency from package.json
#190 (thanks @ramuse !)renderersProps
prop. This lets you pass a set of props to your custom renderers, allowing you to style them furthermore without duplicating the renderers code. For instance, if you create a blockquote
custom renderer, you can alter its color depending on the data you're rendering.Example :
<HTML source={...} renderers={renderers} renderersProps={{ color: 'blue' } />
<HTML source={...} renderers={renderers} renderersProps={{ color: 'red' } />
const renderers = {
blockquote: (htmlAttribs, children, convertedCSSStyles, passProps) => {
const { renderersProps } = passProps;
// rendersProps : { color: blue/red }
return ...
}
}
⚠️ Although this shouldn't be a breaking change, your current rendering might be taking into account the previous buggy implementation. Upgrading to 3.10.0
might break some of your advanced text styling, just because it's now working as it should have from the beginning. ⚠️
<p>
tags. This could have unintended style effects. Let's now wrap them in a new custom tag that behaves like an inline tag, but without styling : textwrapper
ptSize
prop (thanks @ikhsanalatsary)<iframe>
rendering, letting you set their dimensions through tagsStyles
& classesStyles
. These are overriden by height
and width
html attributes. Closes #110fontWeight
property mistakenly got converted from string to a number. This resulted in crashes due to the wrong type. (thanks @mchudy !) Closes #111<img>
if you happen to have a style on your HTML container that's not an array (thanks @ikhsanalatsary) Closes #120!important
annotations that prevented some styles from being rendered Closes #121baseFontStyle
value in README (thanks @charpeni) Closes #116staticContentMaxWidth
and imagesMaxWidth
now have Dimensions.get('window').width
as their default valuesstaticContentMaxWidth
prop, letting you set a maximal width for "non-responsive" renderers (only <iframe>
for now)onLinkPress
: evt
, href
, htmlAttribs
(thanks @barbogast !)allowedStyles
prop, excluding everything but these ones (thanks @krystofcelba !)baseFontStyle
and default text styles, fixes #96getClosestNodeParentByTag
to the available utils functionstextSelectable
prop (thanks @hyb175 !)On iOS, you can copy the text, but not actually select what you want. This is a bug from react-native, see https://github.com/facebook/react-native/issues/13938
<s>
(thanks @hyb175 !)This is very important, especially if you need to update your rendering after it’s been displayed, or simply if you want to use hot reloading.
inherit
styles won't crash the rendering anymore, fixes #87ignoredStyles
prop will now also remove styling passed directly through HTML attributes, see #86lodash.isequal
dependencyRNElements
(basically the representation of your DOM elements into native components) with the onParsed
prop, letting you customize even more your content.parentTag
to elements, fixing an important regression where your tagsStyles
may not be applied. (thanks @Krizzu !)react-native
and its dependencies.alterNode
prop that lets you change the values parsed from your HTML before it's rendered. It's extremely powerful as a last resort to add some very specific styling or circumvent rendering problems.<ul>
and <ol>
styles aren't hardcoded anymore, you can now style them normally. (thanks @jonathonlui !)<a>
tags will properly use your ignoredStyles
prop (thanks @YeatsLu !)baseFontStyle
prop, (replacing baseFontSize
!) allowing you to provide complete default styling to your text elements (#25)listsPrefixesRenderers
prop, allowing you to customize the bullets and numbers rendered in your <ul>
and <ol>
listsimagesInitialDimensions
propremoteLoadingView
& remoteErrorView
propsonParsed
prop, this is fired upon first rendering with the the parsing result of htmlparser2
and of this moduleHTMLImage
: render the alt
attribute when images couldn't be displayedHTMLImage
: width
and height
attribute now resize your imagedebug
prop, printing the parsing result of htmlparser2
and of this module after initial renderingclassesStyles
take precedence over tagsStyles
(#35)<h1>
, <h2>
and so on will always break line between each othersHTMLImage
: don't overscale images when imagesMaxWidth
prop is set to a higher value than the original width of your images<a>
tagstagsStyles
is now applied _constructStyles
so your custom renderers have proper stylingalterData
& alterChildren
props, allowing you to change your HTML data before the intial rendering !baseFontSize
prop won't override the fontSize
set by either : the style
attribute, the tagsStyles
and classesStyles
propcustomWrapper
propViewPropTypes
to get rid of the deprecation warningbaseFontSize
prop so you can change the size of all your texts in a single prop without having to style every text tag (thanks @peacechen !)<br>
tags should receive the styling of their parent properly<p>
<b>Description</b><br />Some description...<br />
Item 1, Item 2, Item 3,
</p>
Item 1, 2, and 3 will be on the same line, regardless of the line breaks of the snippet.
decodeEntities
prop (true
by default)This is a major overhaul of the whole module, adding a lot of features, fixing numerous bugs, and... breaking some things. The whole codebase has been refactored and cleaned-up. The javascript style and linters have been updated accordingly.
This component now comes with a demo that showcases every feature. It will be very useful to keep track of bugs and rendering differences between the different versions of react-native.
It will be mandatory to refer to an example of the demo or to provide one when submitting an issue or a pull request for a new feature.
em
sizing !ignoredTags
prop, you're now able to get rid of those nasty <script> or <blink>
(seriously ?) more easilyignoredStyles
prop. Want to make sure no background-color
is applied through the style
attribute ? You got it<iframes>
& <i>
tagsclassesStyles
prop to style your components with their respective HTML classesignoreNodesFunction
prop so you can ignore HTML tags very precisely<em>
, <i>
, <strong>
... even if they're not wrapped in a parent like <p>
<a>
should behave and receive taps properly<a>
tag without href
attributeCourtesy @duyphambhtech :)
shallowCompare
and replace with PureComponent
<img>
tag has no src attribute<br>
tag<sub>
and <sup>
PropTypes
from prop-types
PropTypes
validators directlyCompatibility with react-native 0.43.2+ (react 16)
Initial release, usable with react >= 0.20 <= 0.42.2 (react 15)
ViewStylePropTypes
and ImageStylesPropTypes
have been deprecated. (thanks @ChrisEdson !)