TreeStateReconciliation.h 1.3 KB

123456789101112131415161718192021222324252627282930313233
  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. #include <react/core/ShadowNode.h>
  8. #include <react/core/ShadowNodeFragment.h>
  9. namespace facebook {
  10. namespace react {
  11. /**
  12. * Problem Description: because of C++ State, the React Native C++ ShadowTree
  13. * can diverge from the ReactJS ShadowTree; ReactJS communicates all tree
  14. * changes to C++, but C++ state commits are not propagated to ReactJS (ReactJS
  15. * may or may not clone nodes with state changes, but it has no way of knowing
  16. * if it /should/ clone those nodes; so those clones may never happen). This
  17. * causes a number of problems. This function resolves the problem by taking a
  18. * candidate tree being committed, and sees if any State changes need to be
  19. * applied to it. If any changes need to be made, a new ShadowNode is returned;
  20. * otherwise, nullptr is returned if the node is already consistent with the
  21. * latest tree, including all state changes.
  22. *
  23. * This should be called during the commit phase, pre-layout and pre-diff.
  24. */
  25. UnsharedShadowNode reconcileStateWithTree(
  26. ShadowNode const *newNode,
  27. SharedShadowNode committedNode);
  28. } // namespace react
  29. } // namespace facebook