mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-05-17 19:33:12 +08:00
Summary:
Recently, I added nullable annotations to ReadableArray, ReadableMap, WritableArray, WritableMap and subclasses to improve Kotlin developer experience. But found that I made mistake with pushArray, pushMap, pushString method of WritableArray, and putArray, putMap, putString methods of WritableMap. This PR fixes previous mistake.
Excerpt from WritableNativeArray.cpp.
```cpp
void WritableNativeArray::pushString(jstring value) {
if (value == NULL) {
pushNull();
return;
}
throwIfConsumed();
array_.push_back(wrap_alias(value)->toStdString());
}
void WritableNativeArray::pushNativeArray(WritableNativeArray* otherArray) {
if (otherArray == NULL) {
pushNull();
return;
}
throwIfConsumed();
array_.push_back(otherArray->consume());
}
void WritableNativeArray::pushNativeMap(WritableNativeMap* map) {
if (map == NULL) {
pushNull();
return;
}
throwIfConsumed();
array_.push_back(map->consume());
}
```
Excerpt from WritableNativeMap.cpp
```cpp
void WritableNativeMap::putString(std::string key, alias_ref<jstring> val) {
if (!val) {
putNull(std::move(key));
return;
}
throwIfConsumed();
map_.insert(std::move(key), val->toString());
}
void WritableNativeMap::putNativeArray(std::string key, WritableNativeArray* otherArray) {
if (!otherArray) {
putNull(std::move(key));
return;
}
throwIfConsumed();
map_.insert(key, otherArray->consume());
}
void WritableNativeMap::putNativeMap(std::string key, WritableNativeMap *otherMap) {
if (!otherMap) {
putNull(std::move(key));
return;
}
throwIfConsumed();
map_.insert(std::move(key), otherMap->consume());
}
```
[Android] [Changed] - fix nullable annotations in WritableArray, WritableMap
Pull Request resolved: https://github.com/facebook/react-native/pull/23397
Differential Revision: D14044014
Pulled By: cpojer
fbshipit-source-id: c44ea2e097e7b1156223b516aa640a181f0d4a9b
Building React Native for Android
See the docs on the website.
Running tests
When you submit a pull request CircleCI will automatically run all tests. To run tests locally, see Testing.