Quernest / mui-modal-provider

🌞 Context API and Hooks based Modal Provider for react material-ui framework
MIT License
77 stars 10 forks source link

Rerenders all components #56

Open JonasRothmann opened 2 years ago

JonasRothmann commented 2 years ago

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

Quernest commented 2 years ago

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

JonasRothmann commented 2 years ago

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!

Quernest commented 2 years ago

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?

kytosai commented 1 year ago

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 ?