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

Can't change the component once it's mounted to the DOM #27

Closed
0xjohnnycagewins opened this issue Oct 17, 2018 · 1 comment
Closed

Can't change the component once it's mounted to the DOM #27

0xjohnnycagewins opened this issue Oct 17, 2018 · 1 comment

Comments

@0xjohnnycagewins
Copy link

I have a use case where the src element of the script tag changes according to the locale used on the website. Since the script src is passed using the url prop, I thought the component would re-render when changing it, but it doesn't. After looking at your code I realized that that the component is never rendered using render(). Rather, you're using observers created in componentDidMount(). It means that once the component has been mounted to the DOM, it will never be re-rendered again.

I know that because of this design choice it probably won't be that easy to make it possible for the component render using the render() method so it gets re-rendered when props change without a possible (major) refactoring. Just wanted to let you guys know about it if you never encountered the problem. If you don't plan on implementing this, maybe adding a note to the documentation would help some people save time since I had to check your code to understand why my component was not rendering correctly.

#14 might be related to this - I haven't used react-router enough so far to fully understand the problem.

@0xjohnnycagewins
Copy link
Author

Just saw this is a duplicate of #1. Closing.

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

1 participant