🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more

react-native-render-html

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-native-render-html

The hackable, full-featured Open Source HTML rendering solution for React Native.

6.3.4
next
latest
foundry
release/6.3
Version published
Weekly downloads
350K
49.99%
Maintainers
3
Weekly downloads
 
Created

What is react-native-render-html?

react-native-render-html is a powerful library for rendering HTML content in React Native applications. It provides a way to display HTML content with support for custom tags, styles, and scripts, making it highly customizable and versatile for various use cases.

What are react-native-render-html's main functionalities?

Basic HTML Rendering

This feature allows you to render basic HTML content within a React Native application. The code sample demonstrates how to use the RenderHTML component to display a simple HTML string.

import React from 'react';
import { SafeAreaView, ScrollView } from 'react-native';
import RenderHTML from 'react-native-render-html';

const htmlContent = `
  <h1>Hello World</h1>
  <p>This is a simple HTML content.</p>
`;

const App = () => {
  return (
    <SafeAreaView>
      <ScrollView>
        <RenderHTML source={{ html: htmlContent }} />
      </ScrollView>
    </SafeAreaView>
  );
};

export default App;

Custom Tag Rendering

This feature allows you to define custom renderers for specific HTML tags. The code sample shows how to render a custom HTML tag with a specific style.

import React from 'react';
import { SafeAreaView, ScrollView, Text } from 'react-native';
import RenderHTML from 'react-native-render-html';

const htmlContent = `
  <custom-tag>Custom Tag Content</custom-tag>
`;

const renderers = {
  'custom-tag': (htmlAttribs, children, convertedCSSStyles, passProps) => {
    return <Text style={{ color: 'blue' }}>{children}</Text>;
  }
};

const App = () => {
  return (
    <SafeAreaView>
      <ScrollView>
        <RenderHTML source={{ html: htmlContent }} renderers={renderers} />
      </ScrollView>
    </SafeAreaView>
  );
};

export default App;

Styling HTML Content

This feature allows you to apply inline styles to HTML content. The code sample demonstrates how to render HTML with inline CSS styles.

import React from 'react';
import { SafeAreaView, ScrollView } from 'react-native';
import RenderHTML from 'react-native-render-html';

const htmlContent = `
  <h1 style="color: red;">Styled Header</h1>
  <p style="font-size: 20px;">This is a styled paragraph.</p>
`;

const App = () => {
  return (
    <SafeAreaView>
      <ScrollView>
        <RenderHTML source={{ html: htmlContent }} />
      </ScrollView>
    </SafeAreaView>
  );
};

export default App;

Other packages similar to react-native-render-html

FAQs

Package last updated on 24 Jan 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts