pmndrs / react-three-fiber

🇨🇭 A React renderer for Three.js
https://docs.pmnd.rs/react-three-fiber
MIT License
27.62k stars 1.6k forks source link

[v9] fix: remove `useUpdate` #3262

Closed krispya closed 6 months ago

krispya commented 6 months ago

Removes the deprecated API for useUpdate. Only issue I saw is that rafz gives a warning when Drei is imported. I am unfamiliar with rafz, an internal library of react-spring, so I couldn't debug it further. It has something to do with global effects, which we intend to deprecate anyways.

codesandbox-ci[bot] commented 6 months ago

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit c49e02a21f8a835f444e05a9fd3e36658555c35e:

Sandbox Source
example Configuration
joshuaellis commented 6 months ago

At the moment r3f drives react spring when used In the context of three because there are instances where you might run frameloop = demand, and the springs would still run. We use a global effect to do this, but to be honest it causes issues between mixing web & three springs.

So I could just remove that and if you run your three app in demand mode, you should run your springs also in demand mode and manage that all yourself, it's relatively easy... would solve a long standing bug...

krispya commented 6 months ago

At the moment r3f drives react spring when used In the context of three because there are instances where you might run frameloop = demand, and the springs would still run. We use a global effect to do this, but to be honest it causes issues between mixing web & three springs.

So I could just remove that and if you run your three app in demand mode, you should run your springs also in demand mode and manage that all yourself, it's relatively easy... would solve a long standing bug...

In v10 we will be replacing the loop with a proper scheduler that will have all the flexibility for controlling third party systems. I think it will solve the problem react-spring is having. In the meantime, v9 isn't making any API changes even though we made updates to the internals, so I wanted to make sure the loop works as expected.

On the Animation example I am getting this error loop.ts:40 Cannot call the manual advancement of rafz whilst frameLoop is not set as demand even though the frameloop is set to always. This looks unexpected, but I'm not sure why it is happening.

But note react-spring isn't working with React 19 in v9 right now.

CodyJasonBennett commented 6 months ago

Maybe due to #3228 instead.

krispya commented 6 months ago

Maybe due to #3228 instead.

I'm thinking we can merge this PR and put the issue aside until react-spring gets an update.