diff --git a/ReactAndroid/src/main/jni/react/jni/WritableNativeArray.cpp b/ReactAndroid/src/main/jni/react/jni/WritableNativeArray.cpp index 21626aeba31a07..227994274955e9 100644 --- a/ReactAndroid/src/main/jni/react/jni/WritableNativeArray.cpp +++ b/ReactAndroid/src/main/jni/react/jni/WritableNativeArray.cpp @@ -17,6 +17,13 @@ namespace react { WritableNativeArray::WritableNativeArray() : HybridBase(folly::dynamic::array()) {} +WritableNativeArray::WritableNativeArray(folly::dynamic &&val) + : HybridBase(std::move(val)) { + if (!array_.isArray()) { + throw std::runtime_error("WritableNativeArray value must be an array."); + } +} + local_ref WritableNativeArray::initHybrid( alias_ref) { return makeCxxInstance(); diff --git a/ReactAndroid/src/main/jni/react/jni/WritableNativeArray.h b/ReactAndroid/src/main/jni/react/jni/WritableNativeArray.h index b4b3e0c660b88d..40a813d21af99c 100644 --- a/ReactAndroid/src/main/jni/react/jni/WritableNativeArray.h +++ b/ReactAndroid/src/main/jni/react/jni/WritableNativeArray.h @@ -29,6 +29,8 @@ struct WritableNativeArray "Lcom/facebook/react/bridge/WritableNativeArray;"; WritableNativeArray(); + WritableNativeArray(folly::dynamic &&val); + static jni::local_ref initHybrid(jni::alias_ref); void pushNull();