Expose "unreserved" trait constants that can be mapped per-component

Summary:
Fabric core uses a lot of traits - I am reserving a few more for core usage, and also exposing a few "unreserved" traits.

It is recommended that all custom components that do use traits rely on these constants instead of hard-coding any trait values. That way, in the unlikely event that these values change in the future, it will not break components.

Changelog: [Internal]

Reviewed By: cortinico, RSNara

Differential Revision: D30401743

fbshipit-source-id: fb2e8f5cf33c94e31a0c25a89055acfc4eccf066
This commit is contained in:
Joshua Gross
2021-08-18 13:23:17 -07:00
committed by Facebook GitHub Bot
parent 22f81b203f
commit 4804e68238
2 changed files with 15 additions and 1 deletions
@@ -240,5 +240,9 @@ ShadowNodeReferenceT traitCast(ShadowNode const &shadowNode);
template <typename ShadowNodePointerT>
ShadowNodePointerT traitCast(ShadowNode const *shadowNode);
template <typename ShadowNodePointerT>
std::shared_ptr<ShadowNodePointerT const> traitCast(
std::shared_ptr<ShadowNode const> shadowNode);
} // namespace react
} // namespace facebook
@@ -21,7 +21,7 @@ class ShadowNodeTraits {
public:
/*
* Underlying type for the traits.
* The first 18 bits are reserved for Core.
* The first 23 bits are reserved for Core.
*/
enum Trait : int32_t {
None = 0,
@@ -88,6 +88,16 @@ class ShadowNodeTraits {
// Inherits 'TextShadowNode'
Text = 1 << 17,
// Reserved
ReservedTrait1 = 1 << 18,
ReservedTrait2 = 1 << 19,
ReservedTrait3 = 1 << 20,
ReservedTrait4 = 1 << 21,
ReservedTrait5 = 1 << 22,
// Unserved - alias these for local usage
UnreservedTrait1 = 1 << 23
};
/*