Skip to content

Commit

Permalink
Use feature flag to enable view manager delegates for setting props
Browse files Browse the repository at this point in the history
Summary: This diff adds a feature flag which must be enabled if view managers should be allowed to use a delegate for setting their properties.

Reviewed By: mdvacca

Differential Revision: D16762876

fbshipit-source-id: ae3466d7f02ed02f203dbb79f5e0843e6d9fdd45
  • Loading branch information
makovkastar authored and facebook-github-bot committed Aug 14, 2019
1 parent 825e1c0 commit 639da37
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,11 @@ public class ReactFeatureFlags {
* This feature flag enables logs for Fabric
*/
public static boolean enableFabricLogs = false;

/**
* Should this application use a {@link com.facebook.react.uimanager.ViewManagerDelegate} (if
* provided) to update the view properties. If {@code false}, then the generated {@code
* ...$$PropsSetter} class will be used instead.
*/
public static boolean useViewManagerDelegates = false;
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.bridge.ReadableArray;
import com.facebook.react.bridge.ReadableMap;
import com.facebook.react.config.ReactFeatureFlags;
import com.facebook.react.touch.JSResponderHandler;
import com.facebook.react.touch.ReactInterceptingViewGroup;
import com.facebook.react.uimanager.annotations.ReactProp;
Expand All @@ -40,8 +41,8 @@ public abstract class ViewManager<T extends View, C extends ReactShadowNode>
* @param stateWrapper
*/
public void updateProperties(@NonNull T viewToUpdate, ReactStylesDiffMap props) {
final ViewManagerDelegate<T> delegate = getDelegate();
if (delegate != null) {
final ViewManagerDelegate<T> delegate;
if (ReactFeatureFlags.useViewManagerDelegates && (delegate = getDelegate()) != null) {
ViewManagerPropertyUpdater.updateProps(delegate, viewToUpdate, props);
} else {
ViewManagerPropertyUpdater.updateProps(this, viewToUpdate, props);
Expand Down

0 comments on commit 639da37

Please sign in to comment.