Replies: 3 comments 11 replies
-
Related discussions I opened: #116, #70 (comment) |
Beta Was this translation helpful? Give feedback.
-
From prior discussions with Andrew, my understanding is that you can't really make use of external state libraries and transitions. That seemed to be the stated limitation of |
Beta Was this translation helpful? Give feedback.
-
WARNING DEEP DIVE BELOW Where is this all going? This isn't just a React thing, it's the same as how in Rust for something to be thread-safe it has to comply to the Send and Sync protocols. If you pass something to like a multi-threaded HTTP server in Rust, that data has to be Send and Sync compatible - which basically means deep immutable or at least transferring ownership of a single copy of it. There are many features that concurrency enables but the final frontier is to allow for true parallel rendering across multiple cores once the runtimes we run in allows it. This means that everything in render have to be "thread safe" at a minimum - in other words it has to be Send/Sync. This doesn't necessarily mean that they have to be fully immutable. For example you can use a Mutex. A Mutex in Rust (or C++) is not very idiomatic. It is a complicated thing to work with. You have to deal with possible "poisoning" and deadlocks. Once you enter this world, you're in "advanced mode". However, it is possible with a Mutex to have mutable data that is also thread-safe. However, just because the data is thread-safe doesn't mean that it's logically consistent. If you read the same or related data at two different times, it might yield logically inconsistent results. This is the same as if you read from a database twice outside a transaction. That might then cause an error path because it's logically inconsistent (even though it's memory safe), which then needs recovery. E.g. sometimes transactions solve this by reexecuting which is also what we do, which is why things mostly work anyway. It has a tradeoff between using a Mutex and the risk that you sometimes has to double the work under the wrong condition. Sometimes you have to resolve the conflict by blocking the main thread. Mostly this will only affect performance though. That's the tradeoff. That's the computer science stuff that underpins all these annoying things. It's not something we made up. If you want to deep dive, I'd recommend just learning concurrent Rust. However, there is also one small thing that we did "make up". In addition to those things, what can happen is that if you use synchronous rendering |
Beta Was this translation helpful? Give feedback.
-
according to this article by @dai-shi it's still spotty: https://github.com/dai-shi/will-this-react-global-state-work-in-concurrent-rendering
what are the steps that react-redux recoil zustand et al, whose state is outside of react, have to take in order to opt into startTransitions?
Test scenario
Results
Raw Output
Beta Was this translation helpful? Give feedback.
All reactions