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

tagsStyles doesn't re-render #343

Closed
DAHUO-Melbourne opened this issue Feb 20, 2020 · 21 comments
Closed

tagsStyles doesn't re-render #343

DAHUO-Melbourne opened this issue Feb 20, 2020 · 21 comments
Labels
bug Crush'em all. is:missing template This issue does not comply with our contribution guidelines.
Projects

Comments

@DAHUO-Melbourne
Copy link

tagsStyles read the font size from store, and the font size changes with the slider bar value. I am sure that the component re-rendered, and I could get the value from store. But the font size in tagsStyles doesn't changes.

@wangyannick
Copy link

wangyannick commented Mar 4, 2020

Same issue here

@castalonirenz
Copy link

Same here any fix?

@edjansantos
Copy link

Same issue here

@castalonirenz
Copy link

i have fix for this, you must declare a key for your render html once the key change it will trigger re-render of your component. hope this help

@huferry
Copy link

huferry commented Apr 13, 2020

i have fix for this, you must declare a key for your render html once the key change it will trigger re-render of your component. hope this help

I'm not quite sure by declare a key. Can you give me an example? (this is a beginner's question, my apologies) Thanks!!

@castalonirenz
Copy link

castalonirenz commented Apr 13, 2020 via email

@aashish-pixere
Copy link

Yes this is working but it's showing some latency while updating the font size.

@castalonirenz
Copy link

castalonirenz commented Apr 15, 2020 via email

@aashish-pixere
Copy link

aashish-pixere commented Apr 16, 2020

what do you mean by latency?

On Wed, Apr 15, 2020 at 6:23 PM Aashish Singhal @.***> wrote: Yes this is working but it's showing some latency while updating the font size. — You are receiving this because you commented. Reply to this email directly, view it on GitHub <#343 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADHUSHMPAQIYONA24GQVVSTRMWDIXANCNFSM4KYIEV3A .

let me explain you again what i am facing issue when i implemented key for html render. Screen always re-rendering, not seems like font size increasing and decreasing smoothly. I hope you got my point and please let me what approach i can use.

If i applied this method forcefully in HTML library (node_modules/react-native-render-html/src/HTML.js ) :

componentWillReceiveProps (nextProps) {
const { html, uri, renderers } = this.props;

     if (html !== nextProps.html || uri !== nextProps.uri) {
         // If the source changed, register the new HTML and parse it
         this.registerDOM(nextProps);
     } else {
         // If it didn't, let's just parse the current DOM and re-render the nodes
         // to compute potential style changes
         this.parseDOM(this.state.dom, nextProps);
     }

}

Then it's work smoothly for font size increase and decreasing after changes with the slider bar but i thought it's not a good way to change in the library. So please guide me what approach i should follow.

@peacechen
Copy link
Contributor

@aashish-pixere
componentWillReceiveProps was replaced by componentDidUpdate (for the most part) in React 16.3.
https://github.com/archriss/react-native-render-html/blob/master/src/HTML.js#L86

Try to replace componentDidUpdate with componentWillUpdate. Remove your additional componentWillReceiveProps callback of course.

If that fixes it, the issue may stem from a feedback loop. The component receives new props, the updates sets state which causes another update, and the process repeats indefinitely.

@mkamals
Copy link

mkamals commented Apr 25, 2020

I'm not quite sure by declare a key. Can you give me an example? (this is a beginner's question, my apologies) Thanks!!

Check this:

const myHTMLTagStyles = {
        p: { fontSize: 18 },
        body: { fontSize: 18 },
    };
<HTML tagsStyles={myHTMLTagStyles} />

@gilmarsquinelato
Copy link

Hello guys, any update on this issue?
We have an open PR that can fix this issue.

I'm working in a product that is using this library, and I needed to use the key workaround.
Without that workaround, we can't properly enable DarkMode on components that uses this renderer.

Thanks!

@jsamr jsamr added bug Crush'em all. is:missing template This issue does not comply with our contribution guidelines. is:waiting pr A pull request is awaiting reviews to solve the problem. labels Jul 4, 2020
@jsamr jsamr added this to In progress in 4.2.2 Jul 5, 2020
@jsamr jsamr closed this as completed in 6e2ed46 Jul 15, 2020
4.2.2 automation moved this from In progress to Done Jul 15, 2020
@jsamr jsamr removed the is:waiting pr A pull request is awaiting reviews to solve the problem. label Jul 17, 2020
@jsamr
Copy link
Collaborator

jsamr commented Jul 24, 2020

In version 4.2.2, HTML component will re-render on tagsStyles and classesStyles changes.
You can test a pre-release version now, see #385.

@amdrade
Copy link
Contributor

amdrade commented Sep 14, 2020

@jsamr thanks for react-native-render-html!

Is possible re-render on baseFontStyle update?
I need to implement a font size control for the user, changing only the baseFontStyle value I don't need to change the style of the other tags manually.

Add || baseFontStyle !== this.props.baseFontStyle on componentDidUpdate work for me.

@jsamr
Copy link
Collaborator

jsamr commented Sep 14, 2020

@amdrade Don't really have much time for this right now, but a PR is welcome!

@nsantacruz
Copy link

@jsamr I see that @amdrade's PR for this (#436) was merged but I don't believe it was ever released. I'm not seeing his commit on master. I'm using v5.0.1

@jsamr
Copy link
Collaborator

jsamr commented Feb 12, 2021

@nsantacruz The dev/4.x branch had diverged from master at that point. I've ported the feature in the 5.1.0 release!

@rabiaah
Copy link

rabiaah commented Sep 1, 2021

Facing issue related to the RTL.
Who can provide RTL css example?

The textAlign is ok, but the paragraph is not for example the Dot starting the paragraph instead of ending it.

@jsamr
Copy link
Collaborator

jsamr commented Sep 1, 2021

@rabiaah If you referring to lists, see https://meliorence.github.io/react-native-render-html/docs/content/lists#experimental-rtl-mode; please ask for anything else in our Discord channel! Thanks.

@rabiaah
Copy link

rabiaah commented Sep 1, 2021

@rabiaah If you referring to lists, see https://meliorence.github.io/react-native-render-html/docs/content/lists#experimental-rtl-mode; please ask for anything else in our Discord channel! Thanks.

Not really related to the lists, I have 2 issues in the attached screenshot:

  1. English string should start the paragraph not ending it.
  2. The Dot should end the paragraph not to starting it.

image

@jsamr
Copy link
Collaborator

jsamr commented Sep 1, 2021

@rabiaah Probably due to RTL not being enabled in your app with I18nManager.forceRTL, see https://reactnative.dev/blog/2016/08/19/right-to-left-support-for-react-native-apps. I'm locking this conversation, don't hesitate to continue the discussion on Discord :-)

@meliorence meliorence locked as resolved and limited conversation to collaborators Sep 1, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Crush'em all. is:missing template This issue does not comply with our contribution guidelines.
Projects
No open projects
4.2.2
  
Done
Development

Successfully merging a pull request may close this issue.