react-native-htmlview icon indicating copy to clipboard operation
react-native-htmlview copied to clipboard

Typing for HTMLViewNode on Typescript

Open lethanhan97 opened this issue 3 years ago • 2 comments

Hey guys, stumbled upon this issue.

When I'm trying to provide the renderNode prop to RNHTMLView using Typescript, an argument node with type HTMLViewNode was provided

The HTMLViewNode type indicate that node doesn't have a type name children. However, it turns out that node does have the children type

Could the type be updated so that children is declared in HTMLViewNode?

const renderNode = (node: HTMLViewNode) => {
    const nodeChildren = node.children // IDE will show error

    // more code
}

Type declaration on react-native-htmlview/index.d.ts

Screenshot 2022-01-20 at 10 59 39 AM

Package info:

  • react-native-htmlview: 0.16.0
  • @types/react-native-html-view: 0.12.2

lethanhan97 avatar Jan 20 '22 02:01 lethanhan97

I am also having this issue and agree that the HTMLViewNode type should be updated to include children. @lethanhan97 it looks like this repo hasn't been updated in quite some time. were you able to find a workaround?

danpettay avatar Apr 20 '22 19:04 danpettay

I added this workaround to the file where I import

const HTML = HTMLView as React.ComponentType<HTMLViewProps>;

then used <HTML {...} /> instead

cooper avatar Nov 28 '23 11:11 cooper