mirror of
https://github.com/facebook/react-native.git
synced 2026-11-18 20:19:07 +00:00
Move nativeId parsing into the Props ctor initializer list (#57339)
Summary: Pull Request resolved: https://github.com/react/react-native/pull/57339 Every Props subclass parses its fields in its 3-arg ctor's initializer list, but `Props` was the odd one out — its 3-arg ctor had an empty initializer list and a body that called a separate `Props::initialize` method, which then assigned `nativeId` and (on Android) ran `initializeDynamicProps`. Fold the `nativeId` parse back into the initializer list and inline the Android `initializeDynamicProps` call into the ctor body, matching the subclass pattern. This removes the only remaining external caller of `Props::initialize`: `YogaStylableProps`'s ctor was constructing its `Props` subobject via `Props()` and then calling `initialize(...)` from its body. Replace with the standard `Props(ctx, sourceProps, rawProps, filterObjectKeys)` initializer-list chain. With both call sites gone, delete `Props::initialize` outright. Behaviour is unchanged: the work that `initialize` did still runs on the same construction path, just via the ctor itself. Changelog: [Internal] Reviewed By: christophpurrer Differential Revision: D109691981 fbshipit-source-id: 835615191332239e90353da2e66fecc429365529
This commit is contained in:
1 parent
e73592ba51
commit
9052f0b427
12 files changed
+15
-41
No files matched your search
+5
-7
@@ -24,13 +24,11 @@ YogaStylableProps::YogaStylableProps(
|
||||
const YogaStylableProps& sourceProps,
|
||||
const RawProps& rawProps,
|
||||
const std::function<bool(const std::string&)>& filterObjectKeys)
|
||||
: Props() {
|
||||
initialize(context, sourceProps, rawProps, filterObjectKeys);
|
||||
|
||||
yogaStyle = ReactNativeFeatureFlags::enableCppPropsIteratorSetter()
|
||||
? sourceProps.yogaStyle
|
||||
: convertRawProp(context, rawProps, sourceProps.yogaStyle);
|
||||
|
||||
: Props(context, sourceProps, rawProps, filterObjectKeys),
|
||||
yogaStyle(
|
||||
ReactNativeFeatureFlags::enableCppPropsIteratorSetter()
|
||||
? sourceProps.yogaStyle
|
||||
: convertRawProp(context, rawProps, sourceProps.yogaStyle)) {
|
||||
if (!ReactNativeFeatureFlags::enableCppPropsIteratorSetter()) {
|
||||
convertRawPropAliases(context, sourceProps, rawProps);
|
||||
}
|
||||
|
||||
@@ -16,23 +16,20 @@
|
||||
namespace facebook::react {
|
||||
|
||||
Props::Props(
|
||||
const PropsParserContext& context,
|
||||
const Props& sourceProps,
|
||||
const RawProps& rawProps,
|
||||
const std::function<bool(const std::string&)>& filterObjectKeys) {
|
||||
initialize(context, sourceProps, rawProps, filterObjectKeys);
|
||||
}
|
||||
|
||||
void Props::initialize(
|
||||
const PropsParserContext& context,
|
||||
const Props& sourceProps,
|
||||
const RawProps& rawProps,
|
||||
[[maybe_unused]] const std::function<bool(const std::string&)>&
|
||||
filterObjectKeys) {
|
||||
nativeId = ReactNativeFeatureFlags::enableCppPropsIteratorSetter()
|
||||
? sourceProps.nativeId
|
||||
: convertRawProp(context, rawProps, "nativeID", sourceProps.nativeId, {});
|
||||
|
||||
filterObjectKeys)
|
||||
: nativeId(
|
||||
ReactNativeFeatureFlags::enableCppPropsIteratorSetter()
|
||||
? sourceProps.nativeId
|
||||
: convertRawProp(
|
||||
context,
|
||||
rawProps,
|
||||
"nativeID",
|
||||
sourceProps.nativeId,
|
||||
{})) {
|
||||
#ifdef RN_SERIALIZABLE_STATE
|
||||
if (!ReactNativeFeatureFlags::enableExclusivePropsUpdateAndroid()) {
|
||||
initializeDynamicProps(sourceProps, rawProps, filterObjectKeys);
|
||||
|
||||
@@ -82,18 +82,6 @@ class Props : public virtual Sealable, public virtual DebugStringConvertible {
|
||||
SharedDebugStringConvertibleList getDebugProps() const override;
|
||||
|
||||
#endif
|
||||
|
||||
protected:
|
||||
/** Initialize member variables of Props instance */
|
||||
void initialize(
|
||||
const PropsParserContext &context,
|
||||
const Props &sourceProps,
|
||||
const RawProps &rawProps,
|
||||
/**
|
||||
* Filter object keys to be excluded when converting the RawProps to
|
||||
* folly::dynamic (android only)
|
||||
*/
|
||||
const std::function<bool(const std::string &)> &filterObjectKeys = nullptr);
|
||||
};
|
||||
|
||||
} // namespace facebook::react
|
||||
@@ -4125,7 +4125,6 @@ class facebook::react::PreparedTextCacheKey {
|
||||
}
|
||||
|
||||
class facebook::react::Props : public virtual facebook::react::Sealable, public virtual facebook::react::DebugStringConvertible {
|
||||
protected void initialize(const facebook::react::PropsParserContext& context, const facebook::react::Props& sourceProps, const facebook::react::RawProps& rawProps, const std::function<bool(const std::string&)>& filterObjectKeys = nullptr);
|
||||
public Props() = default;
|
||||
public Props(const facebook::react::Props& other) = delete;
|
||||
public Props(const facebook::react::PropsParserContext& context, const facebook::react::Props& sourceProps, const facebook::react::RawProps& rawProps, const std::function<bool(const std::string&)>& filterObjectKeys = nullptr);
|
||||
|
||||
@@ -3979,7 +3979,6 @@ class facebook::react::PreparedTextCacheKey {
|
||||
}
|
||||
|
||||
class facebook::react::Props : public virtual facebook::react::Sealable, public virtual facebook::react::DebugStringConvertible {
|
||||
protected void initialize(const facebook::react::PropsParserContext& context, const facebook::react::Props& sourceProps, const facebook::react::RawProps& rawProps, const std::function<bool(const std::string&)>& filterObjectKeys = nullptr);
|
||||
public Props() = default;
|
||||
public Props(const facebook::react::Props& other) = delete;
|
||||
public Props(const facebook::react::PropsParserContext& context, const facebook::react::Props& sourceProps, const facebook::react::RawProps& rawProps, const std::function<bool(const std::string&)>& filterObjectKeys = nullptr);
|
||||
|
||||
@@ -4122,7 +4122,6 @@ class facebook::react::PreparedTextCacheKey {
|
||||
}
|
||||
|
||||
class facebook::react::Props : public virtual facebook::react::Sealable, public virtual facebook::react::DebugStringConvertible {
|
||||
protected void initialize(const facebook::react::PropsParserContext& context, const facebook::react::Props& sourceProps, const facebook::react::RawProps& rawProps, const std::function<bool(const std::string&)>& filterObjectKeys = nullptr);
|
||||
public Props() = default;
|
||||
public Props(const facebook::react::Props& other) = delete;
|
||||
public Props(const facebook::react::PropsParserContext& context, const facebook::react::Props& sourceProps, const facebook::react::RawProps& rawProps, const std::function<bool(const std::string&)>& filterObjectKeys = nullptr);
|
||||
|
||||
@@ -6312,7 +6312,6 @@ class facebook::react::PreparedTextCacheKey {
|
||||
}
|
||||
|
||||
class facebook::react::Props : public virtual facebook::react::Sealable, public virtual facebook::react::DebugStringConvertible {
|
||||
protected void initialize(const facebook::react::PropsParserContext& context, const facebook::react::Props& sourceProps, const facebook::react::RawProps& rawProps, const std::function<bool(const std::string&)>& filterObjectKeys = nullptr);
|
||||
public Props() = default;
|
||||
public Props(const facebook::react::Props& other) = delete;
|
||||
public Props(const facebook::react::PropsParserContext& context, const facebook::react::Props& sourceProps, const facebook::react::RawProps& rawProps, const std::function<bool(const std::string&)>& filterObjectKeys = nullptr);
|
||||
|
||||
@@ -6194,7 +6194,6 @@ class facebook::react::PreparedTextCacheKey {
|
||||
}
|
||||
|
||||
class facebook::react::Props : public virtual facebook::react::Sealable, public virtual facebook::react::DebugStringConvertible {
|
||||
protected void initialize(const facebook::react::PropsParserContext& context, const facebook::react::Props& sourceProps, const facebook::react::RawProps& rawProps, const std::function<bool(const std::string&)>& filterObjectKeys = nullptr);
|
||||
public Props() = default;
|
||||
public Props(const facebook::react::Props& other) = delete;
|
||||
public Props(const facebook::react::PropsParserContext& context, const facebook::react::Props& sourceProps, const facebook::react::RawProps& rawProps, const std::function<bool(const std::string&)>& filterObjectKeys = nullptr);
|
||||
|
||||
@@ -6309,7 +6309,6 @@ class facebook::react::PreparedTextCacheKey {
|
||||
}
|
||||
|
||||
class facebook::react::Props : public virtual facebook::react::Sealable, public virtual facebook::react::DebugStringConvertible {
|
||||
protected void initialize(const facebook::react::PropsParserContext& context, const facebook::react::Props& sourceProps, const facebook::react::RawProps& rawProps, const std::function<bool(const std::string&)>& filterObjectKeys = nullptr);
|
||||
public Props() = default;
|
||||
public Props(const facebook::react::Props& other) = delete;
|
||||
public Props(const facebook::react::PropsParserContext& context, const facebook::react::Props& sourceProps, const facebook::react::RawProps& rawProps, const std::function<bool(const std::string&)>& filterObjectKeys = nullptr);
|
||||
|
||||
@@ -2730,7 +2730,6 @@ class facebook::react::PreparedTextCacheKey {
|
||||
}
|
||||
|
||||
class facebook::react::Props : public virtual facebook::react::Sealable, public virtual facebook::react::DebugStringConvertible {
|
||||
protected void initialize(const facebook::react::PropsParserContext& context, const facebook::react::Props& sourceProps, const facebook::react::RawProps& rawProps, const std::function<bool(const std::string&)>& filterObjectKeys = nullptr);
|
||||
public Props() = default;
|
||||
public Props(const facebook::react::Props& other) = delete;
|
||||
public Props(const facebook::react::PropsParserContext& context, const facebook::react::Props& sourceProps, const facebook::react::RawProps& rawProps, const std::function<bool(const std::string&)>& filterObjectKeys = nullptr);
|
||||
|
||||
@@ -2624,7 +2624,6 @@ class facebook::react::PreparedTextCacheKey {
|
||||
}
|
||||
|
||||
class facebook::react::Props : public virtual facebook::react::Sealable, public virtual facebook::react::DebugStringConvertible {
|
||||
protected void initialize(const facebook::react::PropsParserContext& context, const facebook::react::Props& sourceProps, const facebook::react::RawProps& rawProps, const std::function<bool(const std::string&)>& filterObjectKeys = nullptr);
|
||||
public Props() = default;
|
||||
public Props(const facebook::react::Props& other) = delete;
|
||||
public Props(const facebook::react::PropsParserContext& context, const facebook::react::Props& sourceProps, const facebook::react::RawProps& rawProps, const std::function<bool(const std::string&)>& filterObjectKeys = nullptr);
|
||||
|
||||
@@ -2727,7 +2727,6 @@ class facebook::react::PreparedTextCacheKey {
|
||||
}
|
||||
|
||||
class facebook::react::Props : public virtual facebook::react::Sealable, public virtual facebook::react::DebugStringConvertible {
|
||||
protected void initialize(const facebook::react::PropsParserContext& context, const facebook::react::Props& sourceProps, const facebook::react::RawProps& rawProps, const std::function<bool(const std::string&)>& filterObjectKeys = nullptr);
|
||||
public Props() = default;
|
||||
public Props(const facebook::react::Props& other) = delete;
|
||||
public Props(const facebook::react::PropsParserContext& context, const facebook::react::Props& sourceProps, const facebook::react::RawProps& rawProps, const std::function<bool(const std::string&)>& filterObjectKeys = nullptr);
|
||||
|
||||
Reference in new issue
Block a user