Introducting UIManager.setLocalData(), the way to provide environmental data to ShadowNode

Summary:
In some cases we need a way to provide some peice of data to shadow node
to improve layout (or do something similar), `setLocalData` allows to do this.

Reviewed By: AaaChiuuu

Differential Revision: D5828368

fbshipit-source-id: bf6a04f460dc7695a16269426d365b78909bc8eb
This commit is contained in:
Valentin Shergin
2017-10-02 16:29:42 -07:00
committed by Facebook Github Bot
parent abed3cf6c4
commit d0790fea39
4 changed files with 71 additions and 5 deletions
@@ -181,6 +181,18 @@ public interface ReactShadowNode<T extends ReactShadowNode> {
boolean isDescendantOf(T ancestorNode);
/*
* In some cases we need a way to specify some environmental data to shadow node
* to improve layout (or do something similar), so {@code localData} serves these needs.
* For example, any stateful embedded native views may benefit from this.
* Have in mind that this data is not supposed to interfere with the state of
* the shadow node.
* Please respect one-directional data flow of React.
* Use {@link UIManagerModule#setViewLocalData} to set this property
* (to provide local/environmental data for a shadow node) from the main thread.
*/
public void setLocalData(Object data);
/**
* Returns the offset within the native children owned by all layout-only nodes in the subtree
* rooted at this node for the given child. Put another way, this returns the number of native