-
Notifications
You must be signed in to change notification settings - Fork 158
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Meteor and React V18 incompatibility #354
Comments
I'll try to take a look soon. One note, you really shouldn't do this - it means the |
I can validate this is a problem. The tests are failing in a colossal way. 😓 I'll look in to it. |
So this is only happens when using This does cause some other issues, with events firing out of order. I also found an opportunity to do something we haven't done since a very old version, which is to keep the initial computation in some cases. BUT, that throws off a lot of the tests, and I don't know if it'll be reliable. I'm actually pretty it will not be. I'll need to clean out a lot of tests, if we do it this way (that's probably fine, these are a little too rigid, and brittle). I'll try to get to this this weekend. |
The main problem I'm having with the tests is that the testing platform was updated, and that update is required for using React 18. That update is not backward compatible, so it's going to be tricky to test both React < 17 and React 18+. It looks like things are actually working, but I need to spend some time to get the tests working again. In the mean time, I'll push up a branch over the weekend, so folks can check out the current progress. |
@CaptainN wondering if what you're mentioning is related to this:
Would this cause issues for |
We have supported that (at least, in earlier iterations) for a while. Supporting that is the reason everything double renders (although, I might make an attempt to reduce that - the behavior in 18 is a little different than the last time I looked at it - it seems more stable, which is guess what you might expect). Basically, you really don't want to create side-effects in render - or if you do (like we have to), you just need to clean them up effectively when it goes stale (which is what we do). It makes things tricky because of some magic that Meteor's subscription system does behind the scenes to recycle subscriptions. A lot of this would be simpler if we didn't have to support that. Honestly, this entire pipeline should be reconsidered. We might want to revisit a custom useSubscribe hook, but dig a bit deeper in to the implementation in the DDP side. |
Maybe we can revisit my concept for a useSubscribe that Suspends and create React 18-optimised version of the hooks (that has a peer dependency on ^18)? From what you're saying, it sounds we'll get double benefits; Suspense support for subscriptions (allowing you to simplify your component code), and a simpler useTracker implementation. |
It should actually be possible to support Suspense from within useTracker (and error boundaries). For example, if the subscription isn't ready, we should be able to support a throw directly from there, and pass that up to a Suspense handler. What I would recommend for your custom useSubscription is that you look in to the tests we have for useTracker, and see if those work with your solution. Those are really old tests (they predate my involvement), which can reveal some of those "magic" subscription edge cases that I mentioned. When I restored those in this project a year or so ago, they revealed some real issues with random subscription dropping and other problems like even a rapid sub/unsub loop that would occur sometimes. That's the headache I'm mostly talking about. The main problem, even with suspense, is that it's the interaction with react's lifecycle, and whatever Meteor's subscribe is doing inside that causes these very hard to test for edge cases. Suspense doesn't really solve that on it's own - I really think it would take a deeper dive in to whatever is going on inside the core subscribe function. |
BTW, I do like the idea of supporting Suspense for data loading properly, but I've been waiting for React to send a signal that Suspense is ready to be used for that purpose. Previously, React has made it clear that using Suspense for data is not a supported use for it. It also didn't have support in SSR. It was originally meant to be used for loading components with React.lazy, and didn't have any SSR support. I don't know if those requirements have changed with React 18, but I'll find out. |
I spent a bunch of time over the weekend trying to update the tests to support the change to v18 - it's a lot of work. I'm going to push up the working hook to a PR, and worry about the tests later. It's important to get those working before we release, but the testing platform is proving to be a challenge to get working right. |
Which branch has the working hook for React v18? |
It's up now on |
This is out on version 2.5.0 - has it fixed the issue? |
I had no problems so far. |
Unfortunately the version 2.5.0 breaks my app:
|
@wolasss since you say that it happens irrespective of React version, I think it would make sense to create a new issue for it. |
@denihs @StorytellerCZ When the latest release was made, did we make sure |
Hi @CaptainN, yes. All I did was pull the release to my machine and run the publish command. The |
That rules out this being a problem from packing in a copy of react. My guess it's something else. |
I think it would make sense to create a new issue for it as well. |
Everything is working fine for me now, so I'm closing this issue. |
I have created the following project, to highlight the issue when trying to update React to V18.
https://github.com/KrisjanisStrods/meteor-and-react-V18-incompatibility
Seems to me, that
meteor/react-meteor-data
does not support React V18.The text was updated successfully, but these errors were encountered: