react-nativenode-modulespatch-package

Patching React Native with patch-package not working


I'm trying to fix an issue in React Native, I forked the RN repo, added some code to some java files, and run the rn-tester App, my fix was working fine on the rn-tester App, but when adding this fix to a react-native package inside node_modules directory and patching it using patch-package, my fix not working even if I deleted the node_modules and installed them again, I see my code inside react-native java files but it have no effect on the App.

Also, any Log.d or System.out.println messages appear on the rn-tester App but don't appear on the other App.

Expected

The code fixed the issue on the rn-tester App so it should fix it on the other App.


Solution

  • Because Rect Native takes its Java dependency as an AAR archive any changes to node modules will be skipped. You need to build react native from source as described here: https://reactnative.dev/contributing/how-to-build-from-source