bugfix> android > 投稿

Androidには、次のようなWritableArrayを使用するネイティブモジュールがあります。

public class UploadVideoModule extends ReactContextBaseJavaModule {
public WritableArray test=Arguments.createArray();
 UploadCallBack uploadCallBack = new UploadCallBack() {
        @Override
        public void testArray(int i) {
            test.pushString("aa "+i);
            System.out.println("================= wa test ============test:"+test+" ,size:"+test.size());
        } }
@Override
    public String getName() {
        return REACT_MODULE_NAME;
    }
    public UploadVideoModule(ReactApplicationContext reactContext) {
        super(reactContext);
        WritableArray wa=Arguments.createArray();
        wa.pushString("aaaaaaaaa");
        wa.pushString("bbbbbbbbb");
        wa.pushString("ccccccccc");
        Log.e(TAG,"======= wa ==========="+wa);
        Log.e(TAG,"======= wa ==========size:"+wa.size());
for (int i =0;i<5;i++){
            uploadCallBack.testArray(i);
        }
    }
 interface UploadCallBack {
        void testArray(int i);
    }
}

// ================ログ結果===================

E/tvb.react.uploadvideo.UploadVideoModule: ======= wa ===========["aaaaaaaaa","bbbbbbbbb","ccccccccc"] ======= wa ==========size:3

================= wa test ============test:["aa 0"] ,size:1

================= wa test ============test:["aa 0","aa 1"] ,size:1

================= wa test ============test:["aa 0","aa 1","aa 2"] ,size:1

================= wa test ============test:["aa 0","aa 1","aa 2","aa 3"] ,size:1

================= wa test ============test:["aa 0","aa 1","aa 2","aa 3","aa 4"] ,size:1

これらの結果はとても奇妙です!!!!なぜwaのサイズが正しいのに、テストは常に1ですか? RN 0.51で実行すると、すべてが正常で、サイズが正しいことがわかりました。残念ながら、RN 0.55.4で実行すると問題が発生します。

Environment:

OS: macOS 10.13.4

Node: v9.9.0

npm: 5.6.0

Watchman: 4.9.0

Android Studio: 3.1

Packages: (wanted =>installed)

"react": "16.3.2",

"react-native": "0.55.4", // from 0.51 =>0.55.4

再現する手順 上記のコードをコピーして、RN 0.51と0.55.4で実行すると、その違いがわかります!!