mui-modal-provider icon indicating copy to clipboard operation
mui-modal-provider copied to clipboard

Rerenders all components

Open JonasRothmann opened this issue 2 years ago • 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?

JonasRothmann avatar Mar 29 '22 22:03 JonasRothmann

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 :)

Quernest avatar Apr 05 '22 07:04 Quernest

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!

JonasRothmann avatar Apr 08 '22 06:04 JonasRothmann

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?

Quernest avatar Apr 08 '22 11:04 Quernest

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 ?

kytosai avatar Apr 24 '23 05:04 kytosai