Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Typing for HTMLViewNode on Typescript #340

Open
lethanhan97 opened this issue Jan 20, 2022 · 2 comments
Open

Typing for HTMLViewNode on Typescript #340

lethanhan97 opened this issue Jan 20, 2022 · 2 comments

Comments

@lethanhan97
Copy link

lethanhan97 commented Jan 20, 2022

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
@danpettay
Copy link

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?

@cooper
Copy link

cooper commented Nov 28, 2023

I added this workaround to the file where I import

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

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

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

No branches or pull requests

3 participants