Skip to content

Commit

Permalink
Fabric: New extendend signature of ViewManager::updateState()
Browse files Browse the repository at this point in the history
Summary: Now, the signature of `updateState` method practically copies the signature of `updateLocalData`. We need that to support all features that `updateLocalData` does support now (to migrate from it).

Reviewed By: mdvacca

Differential Revision: D15962377

fbshipit-source-id: 61e0af6c191e0c6a358c5859613e9c512f91d29a
  • Loading branch information
shergin authored and facebook-github-bot committed Jul 8, 2019
1 parent 142af17 commit 71f0079
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ public void createView(
componentName, propsDiffMap, stateWrapper, themedReactContext);
view.setId(reactTag);
if (stateWrapper != null) {
viewManager.updateState(view, stateWrapper);
viewManager.updateState(view, propsDiffMap, stateWrapper);
}
}

Expand Down Expand Up @@ -325,7 +325,11 @@ public void updateState(final int reactTag, StateWrapper stateWrapper) {
if (viewManager == null) {
throw new IllegalStateException("Unable to find ViewManager for tag: " + reactTag);
}
viewManager.updateState(viewState.mView, stateWrapper);
Object extraData =
viewManager.updateState(viewState.mView, viewState.mCurrentProps, stateWrapper);
if (extraData != null) {
viewManager.updateExtraData(viewState.mView, extraData);
}
}

@UiThread
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,10 @@ public Map<String, String> getNativeProps() {
* Subclasses can implement this method to receive state updates shared between all instances of
* this component type.
*/
public void updateState(@Nonnull T view, StateWrapper stateWrapper) {}
public @Nullable Object updateState(
@Nonnull T view, ReactStylesDiffMap props, StateWrapper stateWrapper) {
return null;
}

public long measure(
Context context,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import com.facebook.react.common.MapBuilder;
import com.facebook.react.module.annotations.ReactModule;
import com.facebook.react.uimanager.LayoutShadowNode;
import com.facebook.react.uimanager.ReactStylesDiffMap;
import com.facebook.react.uimanager.StateWrapper;
import com.facebook.react.uimanager.ThemedReactContext;
import com.facebook.react.uimanager.UIManagerModule;
Expand Down Expand Up @@ -101,8 +102,10 @@ protected void onAfterUpdateTransaction(ReactModalHostView view) {
}

@Override
public void updateState(ReactModalHostView view, StateWrapper stateWrapper) {
public Object updateState(
ReactModalHostView view, ReactStylesDiffMap props, StateWrapper stateWrapper) {
Point modalSize = ModalHostHelper.getModalHostSize(view.getContext());
view.updateState(stateWrapper, modalSize.x, modalSize.y);
return null;
}
}

0 comments on commit 71f0079

Please sign in to comment.