jcoreio / react-view-slider

horizontal slide transitions between components
https://jcoreio.github.io/react-view-slider/index.html
MIT License
27 stars 4 forks source link

The renderView prop gets called per the amount of views #53

Open adi-doorloop opened 3 months ago

adi-doorloop commented 3 months ago

I don't understand why it does this, it seems to cause unnecessary re-renders. Explain?

jedwards1211 commented 3 months ago

I could certainly memoize it more. It does need to get called any time the ViewProps for a given view change. So for example, when the active view is changed, it needs to get called for the previous active view (with active: false) and the next active view (with active: true). And the transitionState for both of the views goes through several changes during the transition process as well. I forget if transitionState can change on first mount, later I can check if react-transition-state does so to see if that causes any additional renders.

jedwards1211 commented 3 months ago

I'll think about an API you can use to opt out of calls to changes to ViewProps if you aren't using those props. Using react-view-slider/simple doesn't rerender as much, though I don't know if it's suitable for your use case