Skip to content

Commit 8fb1641

Browse files
javachefacebook-github-bot
authored andcommitted
Add back backwards compat for rawProps.at(x,y,z)
Summary: Restores a deprecated three-argument overload of `RawProps::at()` for backwards compatibility with existing callers (like Nitro modules) that pass prefix/suffix separately. The new overload concatenates `prefix + name + suffix` when needed and delegates to the parser's `at(string_view)` method. When both prefix and suffix are null, it forwards directly to the single-argument version. Changelog: [Internal] Differential Revision: D109837388
1 parent 8371983 commit 8fb1641

11 files changed

Lines changed: 36 additions & 0 deletions

File tree

packages/react-native/ReactCommon/react/renderer/core/RawProps.cpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,4 +116,26 @@ const RawValue* RawProps::at(const char* name) const noexcept {
116116
return parser_->at(*this, name);
117117
}
118118

119+
const RawValue* RawProps::at(
120+
const char* name,
121+
const char* prefix,
122+
const char* suffix) const noexcept {
123+
if (prefix == nullptr && suffix == nullptr) {
124+
return at(name);
125+
}
126+
127+
std::string concatenated;
128+
if (prefix != nullptr) {
129+
concatenated += prefix;
130+
}
131+
concatenated += name;
132+
if (suffix != nullptr) {
133+
concatenated += suffix;
134+
}
135+
react_native_assert(
136+
parser_ &&
137+
"The object is not parsed. `parse` must be called before `at`.");
138+
return parser_->at(*this, concatenated);
139+
}
140+
119141
} // namespace facebook::react

packages/react-native/ReactCommon/react/renderer/core/RawProps.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
#include <limits>
1111
#include <optional>
12+
#include <string>
1213

1314
#include <folly/dynamic.h>
1415
#include <jsi/JSIDynamic.h>
@@ -92,6 +93,10 @@ class RawProps final {
9293
*/
9394
const RawValue *at(const char *name) const noexcept;
9495

96+
// Deprecated: Use at(name) instead. This overload exists for backwards
97+
// compatibility with callers that pass prefix/suffix separately.
98+
const RawValue *at(const char *name, const char *prefix, const char *suffix) const noexcept;
99+
95100
private:
96101
friend class RawPropsParser;
97102

scripts/cxx-api/api-snapshots/ReactAndroidDebugCxx.api

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4190,6 +4190,7 @@ class facebook::react::RawProps {
41904190
public RawProps(folly::dynamic dynamic) noexcept;
41914191
public bool isEmpty() const noexcept;
41924192
public const facebook::react::RawValue* at(const char* name) const noexcept;
4193+
public const facebook::react::RawValue* at(const char* name, const char* prefix, const char* suffix) const noexcept;
41934194
public facebook::react::RawProps& operator=(const facebook::react::RawProps& other) noexcept = delete;
41944195
public facebook::react::RawProps& operator=(facebook::react::RawProps&& other) noexcept = delete;
41954196
public folly::dynamic toDynamic(const std::function<bool(const std::string&)>& filterObjectKeys = nullptr) const;

scripts/cxx-api/api-snapshots/ReactAndroidNewarchCxx.api

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4034,6 +4034,7 @@ class facebook::react::RawProps {
40344034
public RawProps(folly::dynamic dynamic) noexcept;
40354035
public bool isEmpty() const noexcept;
40364036
public const facebook::react::RawValue* at(const char* name) const noexcept;
4037+
public const facebook::react::RawValue* at(const char* name, const char* prefix, const char* suffix) const noexcept;
40374038
public facebook::react::RawProps& operator=(const facebook::react::RawProps& other) noexcept = delete;
40384039
public facebook::react::RawProps& operator=(facebook::react::RawProps&& other) noexcept = delete;
40394040
public folly::dynamic toDynamic(const std::function<bool(const std::string&)>& filterObjectKeys = nullptr) const;

scripts/cxx-api/api-snapshots/ReactAndroidReleaseCxx.api

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4187,6 +4187,7 @@ class facebook::react::RawProps {
41874187
public RawProps(folly::dynamic dynamic) noexcept;
41884188
public bool isEmpty() const noexcept;
41894189
public const facebook::react::RawValue* at(const char* name) const noexcept;
4190+
public const facebook::react::RawValue* at(const char* name, const char* prefix, const char* suffix) const noexcept;
41904191
public facebook::react::RawProps& operator=(const facebook::react::RawProps& other) noexcept = delete;
41914192
public facebook::react::RawProps& operator=(facebook::react::RawProps&& other) noexcept = delete;
41924193
public folly::dynamic toDynamic(const std::function<bool(const std::string&)>& filterObjectKeys = nullptr) const;

scripts/cxx-api/api-snapshots/ReactAppleDebugCxx.api

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6407,6 +6407,7 @@ class facebook::react::RawProps {
64076407
public RawProps(folly::dynamic dynamic) noexcept;
64086408
public bool isEmpty() const noexcept;
64096409
public const facebook::react::RawValue* at(const char* name) const noexcept;
6410+
public const facebook::react::RawValue* at(const char* name, const char* prefix, const char* suffix) const noexcept;
64106411
public facebook::react::RawProps& operator=(const facebook::react::RawProps& other) noexcept = delete;
64116412
public facebook::react::RawProps& operator=(facebook::react::RawProps&& other) noexcept = delete;
64126413
public folly::dynamic toDynamic(const std::function<bool(const std::string&)>& filterObjectKeys = nullptr) const;

scripts/cxx-api/api-snapshots/ReactAppleNewarchCxx.api

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6279,6 +6279,7 @@ class facebook::react::RawProps {
62796279
public RawProps(folly::dynamic dynamic) noexcept;
62806280
public bool isEmpty() const noexcept;
62816281
public const facebook::react::RawValue* at(const char* name) const noexcept;
6282+
public const facebook::react::RawValue* at(const char* name, const char* prefix, const char* suffix) const noexcept;
62826283
public facebook::react::RawProps& operator=(const facebook::react::RawProps& other) noexcept = delete;
62836284
public facebook::react::RawProps& operator=(facebook::react::RawProps&& other) noexcept = delete;
62846285
public folly::dynamic toDynamic(const std::function<bool(const std::string&)>& filterObjectKeys = nullptr) const;

scripts/cxx-api/api-snapshots/ReactAppleReleaseCxx.api

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6404,6 +6404,7 @@ class facebook::react::RawProps {
64046404
public RawProps(folly::dynamic dynamic) noexcept;
64056405
public bool isEmpty() const noexcept;
64066406
public const facebook::react::RawValue* at(const char* name) const noexcept;
6407+
public const facebook::react::RawValue* at(const char* name, const char* prefix, const char* suffix) const noexcept;
64076408
public facebook::react::RawProps& operator=(const facebook::react::RawProps& other) noexcept = delete;
64086409
public facebook::react::RawProps& operator=(facebook::react::RawProps&& other) noexcept = delete;
64096410
public folly::dynamic toDynamic(const std::function<bool(const std::string&)>& filterObjectKeys = nullptr) const;

scripts/cxx-api/api-snapshots/ReactCommonDebugCxx.api

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2772,6 +2772,7 @@ class facebook::react::RawProps {
27722772
public RawProps(folly::dynamic dynamic) noexcept;
27732773
public bool isEmpty() const noexcept;
27742774
public const facebook::react::RawValue* at(const char* name) const noexcept;
2775+
public const facebook::react::RawValue* at(const char* name, const char* prefix, const char* suffix) const noexcept;
27752776
public facebook::react::RawProps& operator=(const facebook::react::RawProps& other) noexcept = delete;
27762777
public facebook::react::RawProps& operator=(facebook::react::RawProps&& other) noexcept = delete;
27772778
public folly::dynamic toDynamic(const std::function<bool(const std::string&)>& filterObjectKeys = nullptr) const;

scripts/cxx-api/api-snapshots/ReactCommonNewarchCxx.api

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2656,6 +2656,7 @@ class facebook::react::RawProps {
26562656
public RawProps(folly::dynamic dynamic) noexcept;
26572657
public bool isEmpty() const noexcept;
26582658
public const facebook::react::RawValue* at(const char* name) const noexcept;
2659+
public const facebook::react::RawValue* at(const char* name, const char* prefix, const char* suffix) const noexcept;
26592660
public facebook::react::RawProps& operator=(const facebook::react::RawProps& other) noexcept = delete;
26602661
public facebook::react::RawProps& operator=(facebook::react::RawProps&& other) noexcept = delete;
26612662
public folly::dynamic toDynamic(const std::function<bool(const std::string&)>& filterObjectKeys = nullptr) const;

0 commit comments

Comments
 (0)