Giter VIP home page Giter VIP logo

Comments (12)

Exilz avatar Exilz commented on May 14, 2024 3

@yjb94 @enguerranws please try the v3.5.1 branch, and specifically this commit.

I guess it should fix it in a clean way.

from react-native-render-html.

enguerranws avatar enguerranws commented on May 14, 2024

I guess it comes form the HTML I provide.

I did a simple test:

<HTML
                  html={`
        <ul>
            <li>Easy</li>
            <li>Peasy</li>
            <li><div style="background-color:red;width:50px;height:50px;"></div></li>
            <li>Lemon</li>
            <li>Squeezy</li>
        </ul>
      
    `}
                  tagsStyles={ HTMLStyles }
                />

This throws the error.

When I replace the content with :

<HTML
                  html={'<p>test</p>'}
                  tagsStyles={ HTMLStyles }
                />

or :

<HTML
                  html={'<p>Here is an <em>ul with <i>li</i></em> tag</p>'}
                  tagsStyles={ HTMLStyles }
                />

There's no error.

from react-native-render-html.

enguerranws avatar enguerranws commented on May 14, 2024

I don't know if this is a good way to solve this, anyway, I did a workaround by adding a simple check in HTML.js:

                         if(typeof(attribs) !== 'undefined') {
                            if (!attribs.style) {
                                child.attribs.style = cssObjectToString(textChildrenInheritedStyles);
                            } else {
                                child.attribs.style = cssObjectToString({
                                    ...textChildrenInheritedStyles,
                                    ...cssStringToObject(child.attribs.style)
                                });
                            }
                        }

From what I see, it works and doesn't break everything. But I'm pretty sure this is not a clean solution to this issue :)

from react-native-render-html.

Exilz avatar Exilz commented on May 14, 2024

Thanks for the workaround. I need some time to dive more into this because attribs should never really be undefined. An empty object, at least.

I'll keep you posted once I know more about this issue.

from react-native-render-html.

enguerranws avatar enguerranws commented on May 14, 2024

@Exilz Thanks! Let me know if I can help you.

from react-native-render-html.

yjb94 avatar yjb94 commented on May 14, 2024

+1

from react-native-render-html.

yjb94 avatar yjb94 commented on May 14, 2024

if(attribs) { if (!attribs.style) { child.attribs.style = cssObjectToString(textChildrenInheritedStyles); } else { child.attribs.style = cssObjectToString({ ...textChildrenInheritedStyles, ...cssStringToObject(child.attribs.style) }); } }

i just managed to add a temporal code for exception..

In my case, the html code was

<p><img src='~~~~~'>SOME_TEXT</p> //didn't work
<p><img src='~~~~~'></p><p>SOME_TEXT</p> //worked

can this help? @Exilz

from react-native-render-html.

Exilz avatar Exilz commented on May 14, 2024

Yeah, your example did help me figure out what's going on.
I think it's just a minor issue, I should be releasing a fix later today.

from react-native-render-html.

yjb94 avatar yjb94 commented on May 14, 2024

Great! it's fixed! thx @Exilz

from react-native-render-html.

enguerranws avatar enguerranws commented on May 14, 2024

Yeah, thanks @Exilz, I'll test it asap!

from react-native-render-html.

enguerranws avatar enguerranws commented on May 14, 2024

@Exilz From what I see, it fixes the issue. When will it be available in master?

from react-native-render-html.

Exilz avatar Exilz commented on May 14, 2024

It's now available on master and on npm. I was waiting for your input. :)

from react-native-render-html.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.