ElementFragment.h 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /*
  2. * Copyright (c) Facebook, Inc. and its affiliates.
  3. *
  4. * This source code is licensed under the MIT license found in the
  5. * LICENSE file in the root directory of this source tree.
  6. */
  7. #pragma once
  8. #include <functional>
  9. #include <memory>
  10. #include <vector>
  11. #include <react/core/ShadowNode.h>
  12. namespace facebook {
  13. namespace react {
  14. /*
  15. * This is an implementation detail, do not use it directly.
  16. * A type-erased version of `Element<>`.
  17. * `ElementFragment` carries all information that is stored inside `Element<>`
  18. * in some generalized, type-erased manner.
  19. */
  20. class ElementFragment final {
  21. public:
  22. using Shared = std::shared_ptr<ElementFragment>;
  23. using List = std::vector<ElementFragment>;
  24. using ListOfShared = std::vector<Shared>;
  25. using ReferenceCallback =
  26. std::function<void(ShadowNode::Unshared const &shadowNode)>;
  27. using FinalizeCallback = std::function<void(ShadowNode &shadowNode)>;
  28. /*
  29. * ComponentDescriptor part (describes the type)
  30. */
  31. ComponentHandle componentHandle;
  32. ComponentName componentName;
  33. /*
  34. * ShadowNodeFamily part (describes the family)
  35. */
  36. Tag tag;
  37. SurfaceId surfaceId;
  38. /*
  39. * ShadowNode part (describes the instance)
  40. */
  41. Props::Shared props;
  42. State::Shared state;
  43. List children;
  44. /*
  45. * Other
  46. */
  47. ReferenceCallback referenceCallback;
  48. FinalizeCallback finalizeCallback;
  49. };
  50. } // namespace react
  51. } // namespace facebook