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

Re-rendering when textComponentProps change #183

Closed
zachdixon opened this issue Nov 29, 2017 · 1 comment
Closed

Re-rendering when textComponentProps change #183

zachdixon opened this issue Nov 29, 2017 · 1 comment

Comments

@zachdixon
Copy link

I'm using textComponentProps to change the text color based on a light/dark theme in my app like this:

textComponentProps={
    {
        style: {
              color: themeStore.theme == "light" ? "#333" : "#d7d7d7"
        }
    }
}

But when my theme changes, htmlview isn't updating with the new styles

@inv2004
Copy link

inv2004 commented Dec 2, 2017

fix:

HTMLView.js

  componentWillReceiveProps(nextProps) {
    if (this.props.value !== nextProps.value
-      || this.props.stylesheet !== nextProps.stylesheet) {
+      || this.props.stylesheet !== nextProps.stylesheet
+      || this.props.textComponentProps !== nextProps.textComponentProps) {
-      this.startHtmlRender(nextProps.value, nextProps.stylesheet);
      this.startHtmlRender(nextProps.value, nextProps.stylesheet, nextProps.textComponentProps);
    }
  }
- startHtmlRender(value, style) {
+ startHtmlRender(value, style, textComponentProps) {

in startHtmlRender(...)

+    if(textComponentProps) {
+     opts['textComponentProps'] = textComponentProps
+    }

    htmlToElement(value, opts, (err, element) => {

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

2 participants