-
-
Notifications
You must be signed in to change notification settings - Fork 130
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
Type errors with v5.0.0 #1126
Comments
For the 1st error, can you return void since the return type should either be a React element or void (returning the domNode shouldn't really do anything): - return domNode // error 1
+ return For the 2nd error, can you use type assertion: - return <>{domToReact(domNode.children, options)}</> // error 2
+ return <>{domToReact((domNode as Element).children as DOMNode[], options)}</>
You can import import { Element, DOMNode } from 'html-react-parser'; |
Thanks, the method works. |
Fixes #1126 Maintains backward compatibility for invalid return type
I decided to add back the |
` const options: HTMLReactParserOptions = { {domToReact(domNode.children as DOMNode[])} ); }
};` |
@Bkumar48 can you open a new issue and provide a reproducible example? |
The following code gives two errors:
Error 1:
It seems
HTMLReactParserOptions
'sreplace
expects JSX.Element instead of domhandler's ElementError 2:
Expected Behavior
There's no type errors
Actual Behavior
Build fails.
Steps to Reproduce
Use the above code
Reproducible Demo
Environment
Keywords
Type error
The text was updated successfully, but these errors were encountered: