Quernest/mui-modal-provider

Rerenders all components

Opened this issue · 4 comments

Is it a known issue/just a factor of React Contexts that all components using this library rerenders when a new library calls useModal?

Is it a known issue/just a factor of React Contexts that all components using this library rerenders when a new library calls useModal?

Given that modal components with props are stored in the object in the Context - yes, any change in it causes the re-rendering of components dependent on this Context.

React is really very fast and it should not cause any noticeable problems, but I'll think about optimizing this stuff, I'm also open to suggestions :)

It made me refetch a bunch of data when combining with Apollo Client, so I just seperated it into two contexts, one that just had showModal - this meant I never rerendered when state changed!

It made me refetch a bunch of data when combining with Apollo Client, so I just seperated it into two contexts, one that just had showModal - this meant I never rerendered when state changed!

If you don't mind, could you send me an example?

It made me refetch a bunch of data when combining with Apollo Client, so I just seperated it into two contexts, one that just had showModal - this meant I never rerendered when state changed!

You can share example ?