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

Markup component will not update if the mapping of custom elements change #25

Open
d3x7r0 opened this issue May 24, 2019 · 2 comments
Open

Comments

@d3x7r0
Copy link

d3x7r0 commented May 24, 2019

When using the option to add a map of custom elements the component will not update if said mapping changes.

I think the problem might be here:

shouldComponentUpdate({ wrap, type, markup }) {
let p = this.props;
return wrap!==p.wrap || type!==p.type || markup!==p.markup;
}

Now I don't know if this is intended behaviour or just a oversight.

@developit
Copy link
Owner

developit commented Jul 10, 2019

@d3x7r0 it's an oversight, but I think if we want to add support for updating when the listing changes we'll need to deeply compare the object values within props.components:

- shouldComponentUpdate({ wrap, type, markup }) { 
+ shouldComponentUpdate({ wrap, type, markup, components }) { 
	let p = this.props; 
+	if (Object.keys(components).join()!=Object.keys(p.components).join()) return true;
+	for (let i in Object(components)) if (components[i]!==p.components[i]) return true;
	return wrap!==p.wrap || type!==p.type || markup!==p.markup; 
 }

@d3x7r0
Copy link
Author

d3x7r0 commented Jul 10, 2019

That looks like it might be a good enough solution yes. I'm also going to steal that key comparison for my toolset. I never thought of doing it that way but it's such a great idea I'm going to keep it handy :)

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