Use feature flag to enable view manager delegates for setting props

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
This commit is contained in:
Oleksandr Melnykov 2019-08-14 03:26:19 -07:00 коммит произвёл Facebook Github Bot
Родитель 825e1c087c
Коммит 639da37dc5
2 изменённых файлов: 10 добавлений и 2 удалений

Просмотреть файл

@ -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;
}

Просмотреть файл

@ -14,6 +14,7 @@ import com.facebook.react.bridge.BaseJavaModule;
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;
@ -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);