mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
110b191b14
Summary: Previously, ViewPropsMapBuffer conversions were hardcoded deep in Android infrastructrue. I've generalized this into a different mechanism to allow any Props struct to support MapBuffer props. There are still some things that need to be cleaned up and this should be treated as experimental. One thing we likely want to do is remove the hardcoded IDs (fine for codegen'd code; less so for handwritten) and use compile-time-hashed IDs instead with human-readable string names. Changelog: [Internal] Reviewed By: mdvacca Differential Revision: D38708719 fbshipit-source-id: 64603dee7f21828be31346c555d99862dab304ea
38 lines
847 B
C++
38 lines
847 B
C++
/*
|
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*/
|
|
|
|
#include "PropsMapBuffer.h"
|
|
#include "Props.h"
|
|
|
|
#include <react/renderer/mapbuffer/MapBufferBuilder.h>
|
|
|
|
namespace facebook {
|
|
namespace react {
|
|
|
|
#ifdef ANDROID
|
|
void Props::propsDiffMapBuffer(
|
|
Props const *oldPropsPtr,
|
|
MapBufferBuilder &builder) const {
|
|
// Call with default props if necessary
|
|
if (oldPropsPtr == nullptr) {
|
|
Props defaultProps{};
|
|
propsDiffMapBuffer(&defaultProps, builder);
|
|
return;
|
|
}
|
|
|
|
Props const &oldProps = *oldPropsPtr;
|
|
Props const &newProps = *this;
|
|
|
|
if (oldProps.nativeId != newProps.nativeId) {
|
|
builder.putString(PROPS_NATIVE_ID, nativeId);
|
|
}
|
|
}
|
|
#endif
|
|
|
|
} // namespace react
|
|
} // namespace facebook
|