You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Yeah, we (Sebastian+Jordan+Myself) were discussing this a few months back. The problem is that the mental model of PureRenderMixin is "if props change, the component will rerender". If you ignore functions, then someone could get in the situation where they ARE changing the function (eg. capturing a variable within a closure) and the component does not update, and it becomes very hard to debug and difficult to reason about because it breaks the mental model.
That said, ignoring function changes is "usually" safe, and can improve the performance of your app. It's worth noting that PureRenderMixin is literally only a couple lines of code. If you wanted to write a version that didn't cause a rerender when function references change, it would be very easy to do so. Such a thing can be done entirely in user land. If you find it useful, I would encourage you to make it open source so other people can take advantage of the same functionality.
I'm going to close this out, which takes it off our todo list, because this is probably not something we'd do in the React core. Feel free to continue the discussion on this thread and/or build in userland.
If I use PureRenderMixin in MyComponent, it will updates every time because of the rootRef. Maybe i can store the function like
But it seems redundant.
If function is ignored, It will be helpful.
The text was updated successfully, but these errors were encountered: