Mojang / ore-ui

💎 Building blocks to construct game UIs using web tech.
https://react-facet.mojang.com/
MIT License
404 stars 19 forks source link

Defer again after initial defer has been completed #110

Closed AdamRamberg closed 8 months ago

AdamRamberg commented 1 year ago

Before this PR the <DeferredMountProvider/> would never defer again after initial deferring has been completed. In practice this meant that if a new child with a <DeferredMount/> or with a <DeferredMountWithCallback/> was mounted added after initial deferring was completed, the useIsDeferring() hook would still return false. This PR changes that behaviour and sets the defer state to true every time a new child with <DeferredMount/> or <DeferredMountWithCallback/> is mounted. An example of where this behaviour would be useful and expected is when you have routing inside a <DeferredMountProvider/>.

AdamRamberg commented 1 year ago

@marlonicus As mentioned above, adjusted the test according to your feedback!

I also want to mention that I removed the requestingToRun state, since it is no longer needed (the 2nd effect will always first time anyways and after that the state works exactly like the isDeferring state).

pirelenito commented 8 months ago

As we are deprecating @react-facet/deferred-mount with #59, I'm closing this PR.