Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

A html render for react-native

NotificationsYou must be signed in to change notification settings

labithiotis/react-native-html-render

 
 

Repository files navigation

A component which takes HTML content and renders it as native views.

Props

  • value: a string of HTML content to render
  • onLinkPress: a function which will be called with a url when a link is pressed.Passing this prop will override how links are handled (defaults to callingLinking.openURL(url))
  • stylesheet: a stylesheet object keyed by tag name, which will override thestyles applied to those respective tags.
  • renderNode: a custom function to render HTML nodes however you see fit. Ifthe function returnsundefined (notnull), the default renderer will beused for that node.

example

importReact,{Component}from'react'importReactNativefrom'react-native'const{ Text, View, ListView}=ReactNativeconstHTMLView=require('react-native-html2native')classAppextendsComponent{render(){constcontent='<p><a href="http://google.com">Google it FTW!</a></p>'return(<HTMLViewvalue={content}stylesheet={styles}/>)}})conststyles=StyleSheet.create({a:{fontWeight:'300',color:'#FF0000'}})

When a link is clicked, by defaultReactNative.Linking.openURL is called with thelink url. You can customise what happens when a link is clicked withonLinkPress:

importReact,{Component}from'react'importReactNativefrom'react-native'classContentViewextendsComponent{render(){return(<HTMLViewvalue={this.props.html}onLinkPress={(url)=>console.log('Link clicked: ',url)}/>)}})

About

A html render for react-native

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript100.0%

[8]ページ先頭

©2009-2025 Movatter.jp