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

Whole component is always re-rendered #50

Open
PetrGlad opened this issue Sep 27, 2015 · 2 comments
Open

Whole component is always re-rendered #50

PetrGlad opened this issue Sep 27, 2015 · 2 comments

Comments

@PetrGlad
Copy link

I have animation at top "main" component. I found out that when I change property of a component that is nested inside "main", the whole "main" component is re-rendered. Besides performance, this causes problems when there is a text input field which loses focus after re-render.
Also it is strange that I had to add componentShouldUpdate to make animations work. It enables animations even when componentShouldUpdate always return true.

This can be reproduced only by adding tweenstate.Mixin without any animations enabled.
I use Om (Clojurescript), ReactJS 13.3 and react-tween-state from master.

BTW, would you recommend using chenglou/react-motion instead?

@chenglou
Copy link
Owner

React-motion doesn't cover ordinary animation (only spring), but that's the way to go anyway. You should try it. Though React-motion also re-renders your thing. I know you're in Cljs but have you tried sprinkling some StaticContainer? Though shouldComponentUpdate isn't exposed in Om right?

@PetrGlad
Copy link
Author

I tried also using react-spring but it still has some strange interactions with how Om detects state changes. E.g. it does not reflect local component's state changes if the component is inside react-spring. shouldComponentUpdate is available for override in Om but it cannot force update if Om does not consider it. This is what I do not like in Om - too much magic and it's not clear where to look when things break. So I better stay on trodden way: I have re-implemented the animations with CSS transitions (they turned out to be sufficient in my case). I never seen StaticContainer before,I'll have a look at it.

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