mirror of
https://github.com/facebook/react-native.git
synced 2026-11-18 20:19:07 +00:00
Add back backwards compat for rawProps.at(x,y,z) (#57346)
Summary: Pull Request resolved: https://github.com/react/react-native/pull/57346 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] Reviewed By: cortinico Differential Revision: D109837388 fbshipit-source-id: c16188cee163ca786f4530d07475f561a53c51b6
This commit is contained in:
1 parent
c6f29a2173
commit
ce72288bfc
11 files changed
+36
No files matched your search
@@ -116,4 +116,26 @@ const RawValue* RawProps::at(const char* name) const noexcept {
|
||||
return parser_->at(*this, name);
|
||||
}
|
||||
|
||||
const RawValue* RawProps::at(
|
||||
const char* name,
|
||||
const char* prefix,
|
||||
const char* suffix) const noexcept {
|
||||
if (prefix == nullptr && suffix == nullptr) {
|
||||
return at(name);
|
||||
}
|
||||
|
||||
std::string concatenated;
|
||||
if (prefix != nullptr) {
|
||||
concatenated += prefix;
|
||||
}
|
||||
concatenated += name;
|
||||
if (suffix != nullptr) {
|
||||
concatenated += suffix;
|
||||
}
|
||||
react_native_assert(
|
||||
parser_ &&
|
||||
"The object is not parsed. `parse` must be called before `at`.");
|
||||
return parser_->at(*this, concatenated);
|
||||
}
|
||||
|
||||
} // namespace facebook::react
|
||||
@@ -9,6 +9,7 @@
|
||||
|
||||
#include <limits>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
|
||||
#include <folly/dynamic.h>
|
||||
#include <jsi/JSIDynamic.h>
|
||||
@@ -92,6 +93,10 @@ class RawProps final {
|
||||
*/
|
||||
const RawValue *at(const char *name) const noexcept;
|
||||
|
||||
// Deprecated: Use at(name) instead. This overload exists for backwards
|
||||
// compatibility with callers that pass prefix/suffix separately.
|
||||
const RawValue *at(const char *name, const char *prefix, const char *suffix) const noexcept;
|
||||
|
||||
private:
|
||||
friend class RawPropsParser;
|
||||
|
||||
|
||||
@@ -4190,6 +4190,7 @@ class facebook::react::RawProps {
|
||||
public RawProps(folly::dynamic dynamic) noexcept;
|
||||
public bool isEmpty() const noexcept;
|
||||
public const facebook::react::RawValue* at(const char* name) const noexcept;
|
||||
public const facebook::react::RawValue* at(const char* name, const char* prefix, const char* suffix) const noexcept;
|
||||
public facebook::react::RawProps& operator=(const facebook::react::RawProps& other) noexcept = delete;
|
||||
public facebook::react::RawProps& operator=(facebook::react::RawProps&& other) noexcept = delete;
|
||||
public folly::dynamic toDynamic(const std::function<bool(const std::string&)>& filterObjectKeys = nullptr) const;
|
||||
|
||||
@@ -4034,6 +4034,7 @@ class facebook::react::RawProps {
|
||||
public RawProps(folly::dynamic dynamic) noexcept;
|
||||
public bool isEmpty() const noexcept;
|
||||
public const facebook::react::RawValue* at(const char* name) const noexcept;
|
||||
public const facebook::react::RawValue* at(const char* name, const char* prefix, const char* suffix) const noexcept;
|
||||
public facebook::react::RawProps& operator=(const facebook::react::RawProps& other) noexcept = delete;
|
||||
public facebook::react::RawProps& operator=(facebook::react::RawProps&& other) noexcept = delete;
|
||||
public folly::dynamic toDynamic(const std::function<bool(const std::string&)>& filterObjectKeys = nullptr) const;
|
||||
|
||||
@@ -4187,6 +4187,7 @@ class facebook::react::RawProps {
|
||||
public RawProps(folly::dynamic dynamic) noexcept;
|
||||
public bool isEmpty() const noexcept;
|
||||
public const facebook::react::RawValue* at(const char* name) const noexcept;
|
||||
public const facebook::react::RawValue* at(const char* name, const char* prefix, const char* suffix) const noexcept;
|
||||
public facebook::react::RawProps& operator=(const facebook::react::RawProps& other) noexcept = delete;
|
||||
public facebook::react::RawProps& operator=(facebook::react::RawProps&& other) noexcept = delete;
|
||||
public folly::dynamic toDynamic(const std::function<bool(const std::string&)>& filterObjectKeys = nullptr) const;
|
||||
|
||||
@@ -6407,6 +6407,7 @@ class facebook::react::RawProps {
|
||||
public RawProps(folly::dynamic dynamic) noexcept;
|
||||
public bool isEmpty() const noexcept;
|
||||
public const facebook::react::RawValue* at(const char* name) const noexcept;
|
||||
public const facebook::react::RawValue* at(const char* name, const char* prefix, const char* suffix) const noexcept;
|
||||
public facebook::react::RawProps& operator=(const facebook::react::RawProps& other) noexcept = delete;
|
||||
public facebook::react::RawProps& operator=(facebook::react::RawProps&& other) noexcept = delete;
|
||||
public folly::dynamic toDynamic(const std::function<bool(const std::string&)>& filterObjectKeys = nullptr) const;
|
||||
|
||||
@@ -6279,6 +6279,7 @@ class facebook::react::RawProps {
|
||||
public RawProps(folly::dynamic dynamic) noexcept;
|
||||
public bool isEmpty() const noexcept;
|
||||
public const facebook::react::RawValue* at(const char* name) const noexcept;
|
||||
public const facebook::react::RawValue* at(const char* name, const char* prefix, const char* suffix) const noexcept;
|
||||
public facebook::react::RawProps& operator=(const facebook::react::RawProps& other) noexcept = delete;
|
||||
public facebook::react::RawProps& operator=(facebook::react::RawProps&& other) noexcept = delete;
|
||||
public folly::dynamic toDynamic(const std::function<bool(const std::string&)>& filterObjectKeys = nullptr) const;
|
||||
|
||||
@@ -6404,6 +6404,7 @@ class facebook::react::RawProps {
|
||||
public RawProps(folly::dynamic dynamic) noexcept;
|
||||
public bool isEmpty() const noexcept;
|
||||
public const facebook::react::RawValue* at(const char* name) const noexcept;
|
||||
public const facebook::react::RawValue* at(const char* name, const char* prefix, const char* suffix) const noexcept;
|
||||
public facebook::react::RawProps& operator=(const facebook::react::RawProps& other) noexcept = delete;
|
||||
public facebook::react::RawProps& operator=(facebook::react::RawProps&& other) noexcept = delete;
|
||||
public folly::dynamic toDynamic(const std::function<bool(const std::string&)>& filterObjectKeys = nullptr) const;
|
||||
|
||||
@@ -2772,6 +2772,7 @@ class facebook::react::RawProps {
|
||||
public RawProps(folly::dynamic dynamic) noexcept;
|
||||
public bool isEmpty() const noexcept;
|
||||
public const facebook::react::RawValue* at(const char* name) const noexcept;
|
||||
public const facebook::react::RawValue* at(const char* name, const char* prefix, const char* suffix) const noexcept;
|
||||
public facebook::react::RawProps& operator=(const facebook::react::RawProps& other) noexcept = delete;
|
||||
public facebook::react::RawProps& operator=(facebook::react::RawProps&& other) noexcept = delete;
|
||||
public folly::dynamic toDynamic(const std::function<bool(const std::string&)>& filterObjectKeys = nullptr) const;
|
||||
|
||||
@@ -2656,6 +2656,7 @@ class facebook::react::RawProps {
|
||||
public RawProps(folly::dynamic dynamic) noexcept;
|
||||
public bool isEmpty() const noexcept;
|
||||
public const facebook::react::RawValue* at(const char* name) const noexcept;
|
||||
public const facebook::react::RawValue* at(const char* name, const char* prefix, const char* suffix) const noexcept;
|
||||
public facebook::react::RawProps& operator=(const facebook::react::RawProps& other) noexcept = delete;
|
||||
public facebook::react::RawProps& operator=(facebook::react::RawProps&& other) noexcept = delete;
|
||||
public folly::dynamic toDynamic(const std::function<bool(const std::string&)>& filterObjectKeys = nullptr) const;
|
||||
|
||||
@@ -2769,6 +2769,7 @@ class facebook::react::RawProps {
|
||||
public RawProps(folly::dynamic dynamic) noexcept;
|
||||
public bool isEmpty() const noexcept;
|
||||
public const facebook::react::RawValue* at(const char* name) const noexcept;
|
||||
public const facebook::react::RawValue* at(const char* name, const char* prefix, const char* suffix) const noexcept;
|
||||
public facebook::react::RawProps& operator=(const facebook::react::RawProps& other) noexcept = delete;
|
||||
public facebook::react::RawProps& operator=(facebook::react::RawProps&& other) noexcept = delete;
|
||||
public folly::dynamic toDynamic(const std::function<bool(const std::string&)>& filterObjectKeys = nullptr) const;
|
||||
|
||||
Reference in new issue
Block a user