nuclearpasta / react-native-drax

A drag-and-drop system for React Native
MIT License
554 stars 68 forks source link

New Architecture Support - measureLayout() is obsolete with native node handlers #176

Open LunatiqueCoder opened 1 month ago

LunatiqueCoder commented 1 month ago

Hello

This PR fixes:


The Problem

SOURCE: React Native Docs - Direct Manipulation: measureLayout()

image

Conclusion

On the new architecture, measureLayout() with a relativeToNativeNode handler (instead of reference) is OBSOLETE

I also opened a PR to update React Native Docs:


While passing a view ref will make it WORK with the new architecture, we should still use the new architecture capabilities.

From my testing this works fine, but I would love if the community reviews it and tests it.

Let me know if anyone needs help to test those changes!

Cheers 🍻

lafiosca commented 1 month ago

@LunatiqueCoder I think for now I am going to be very dependent on your word for if/when this is ready to go.

LunatiqueCoder commented 1 month ago

@lafiosca From my side, it's working like a charm.

If I turn on the new architecture, there is no error. If I revert the changes, and I still have the new architecture on, I got the error:

 (NOBRIDGE) LOG  Bridgeless mode is enabled
 (NOBRIDGE) ERROR  Warning: ref.measureLayout must be called with a ref to a native component.


Error is pretty self describing, and the fix is also easy 🚀 just deleted code and passed in the ref instead of the node handle :)

lafiosca commented 1 month ago

@LunatiqueCoder One more request... can you identify which minimum version of RN is required for this and update the README and peer deps?

LunatiqueCoder commented 4 weeks ago

@lafiosca I think this change shouldn't break older React Native versions. However, it would be nice to bump devDependencies.

Also, I would suggest to use Expo's eslint config for OSS projects, it's pretty cool.

LunatiqueCoder commented 5 days ago

@lafiosca The new architecture is now enabled by default on new react native projects. Soon will be for expo too. Let me know if I can help. I'm always available on Discord.