javaandroidreact-nativeui-testing

Modifying react-native files


i changed a BaseViewManager.java file inside of react-native to make resource-id available thru react-native. the thing is that no matter what i do, nothing takes effect, even if i put typos in the .java files. my colleague told me it's probably because the .java is not being built.

so how to build the react-native .java files??

i tried npm start of course but nothing took any effect.

and this is the code that i want to change

@ReactProp(name = PROP_TEST_ID)
  public void setTestId(T view, String testId) {
    view.setTag(R.id.react_test_id, testId);

    // temporarily set the tag and keyed tags to avoid end to end test regressions
    view.setTag(testId);
  }

  @ReactProp(name = PROP_NATIVE_ID)
  public void setNativeId(T view, String nativeId) {
    view.setTag(R.id.view_tag_native_id, nativeId);
    ReactFindViewUtil.notifyViewRendered(view);
}

Solution

  • You have to build React Native from source. Here is tutorial for that: https://reactnative.dev/contributing/how-to-build-from-source I tried it and it works :)