-
-
Notifications
You must be signed in to change notification settings - Fork 134
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
Error: img is a void element tag and must neither have children
nor use dangerouslySetInnerHTML
#14
Comments
Thanks for letting me know. Do you have an example so I can reproduce this error? |
Hi! |
- Fix void element bug (#14) - Void elements like <img> should not have any children (even an empty array `[]` counts as children) - Pass `key` to the `replace` method as the second parameter - Prevent React "key" warning - Update tests, mocks, and helpers - Update README with update on `replace` method
Awesome, thank you! |
@poacher2k Thanks for the example. I've looked into the bug and made a fix in #16. Try |
That fixed it, thanks again! Glad to see you also added checks for other void elements! |
Great to hear and you're very welcome! 👍 |
@remarkablemark I am still facing the issue and npm install [email protected] code is not updated in this version. |
@vidit1 Can you confirm that you installed the npm i html-react-parser@latest
# or
npm i [email protected] Then verify by doing: npm ls html-react-parser |
@remarkablemark I updated the latest version html-react-parser and still face this issue. My |
@blueskysmart : You have the text "Bootstrap" inside your See @remarkablemark 's comment below for guidance on how to fix it. |
@blueskysmart The comment made by @poacher2k is correct. You can see the reproduction of this error in this fiddle. |
Okie, I see. Thank you. |
This error comes up also if you only try to parse this: To make it work, wrap it in a div:
|
I was running into this issue because I was trying to add children to an img tag... |
Hi!
Great plugin, really think this is going to be helpful for what I'm working on.
I noticed that parsing any
img
-element causes the above error. This may also apply to any element that never should have child elements.A temporary workaround is to use something like this:
The text was updated successfully, but these errors were encountered: