Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

If asynchronous layout were the culprit, presumably that's the precise type of issue that react-native-reanimated solves? It seems to me that the experiences created via react-native-reanimated run quite smoothly indeed. Of course, the developer still has to reimplement interactions otherwise provided by iOS etc, but React Native should not be a reason for things like sloppy interactions.


The animated package doesn’t come into play here. When the layout needs to be recomputed in RN, it does it asynchronously - regardless of what’s calling it. Part of this can be explained because the JS can hook listen for layout updates via the onLayout prop and make changes to the layout - and could in theory cause infinite loops. But there’s no mechanism - as far as I’m aware - to say you don’t care about that detail and just do it synchronously anyway


I believe you're confusing react-native-reanimated (https://github.com/software-mansion/react-native-reanimated) with the Animated API from React Native. react-native-reanimated allows JS code to run on a UI thread that is able to synchronously modify layout, providing alternative synchronous ways for you to hook into the layouting. For instance, as opposed to the asynchronous `measure()` method provided by React Native to measure layouts, react-native-reanimated allows one to call their version of `measure()` (https://docs.swmansion.com/react-native-reanimated/docs/api/...) to perform the same operation on the UI thread, synchronously.


I meant both Animated APIs - neither is able to perform synchronous layouts - because react native is not able to do that. That’s the issue that’s stopping the page sheet controllers being added to react native. I actually was helping getting this added, but we never managed to get the layout issues fixed - https://github.com/facebook/react-native/pull/34834

The measure function you mention isn’t co-ordinated to the layout, so you could read it while a layout is pending and get old data - but that doesn't really matter for most cases


In that case I would stand corrected.

May I ask, does the New Architecture and Fabric not solve this problem?


They keep saying you can do it - but I can’t actually see how. I don’t do a whole lot with the new architecture at the moment - it’s still very new and a very bumpy ride if you want to adopt it




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: