From 02f734bdee71f9236e5b13521e6ea2940170bdd0 Mon Sep 17 00:00:00 2001 From: Website Deployment Script Date: Mon, 31 Jul 2017 11:09:35 +0000 Subject: [PATCH] Updated docs for next --- releases/next/docs/native-components-android.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/releases/next/docs/native-components-android.html b/releases/next/docs/native-components-android.html index 9b7135a5663..54a62bd5426 100644 --- a/releases/next/docs/native-components-android.html +++ b/releases/next/docs/native-components-android.html @@ -11,8 +11,8 @@ public ReactImageView createViewInstance(ThemedReactContext context) { return new ReactImageView(context, Fresco.newDraweeControllerBuilder(), mCallerContext); }

3. Expose view property setters using @ReactProp (or @ReactPropGroup) annotation #

Properties that are to be reflected in JavaScript needs to be exposed as setter method annotated with @ReactProp (or @ReactPropGroup). Setter method should take view to be updated (of the current view type) as a first argument and property value as a second argument. Setter should be declared as a void method and should be public. Property type sent to JS is determined automatically based on the type of value argument of the setter. The following type of values are currently supported: boolean, int, float, double, String, Boolean, Integer, ReadableArray, ReadableMap.

Annotation @ReactProp has one obligatory argument name of type String. Name assigned to the @ReactProp annotation linked to the setter method is used to reference the property on JS side.

Except from name, @ReactProp annotation may take following optional arguments: defaultBoolean, defaultInt, defaultFloat. Those arguments should be of the corresponding primitive type (accordingly boolean, int, float) and the value provided will be passed to the setter method in case when the property that the setter is referencing has been removed from the component. Note that "default" values are only provided for primitive types, in case when setter is of some complex type, null will be provided as a default value in case when corresponding property gets removed.

Setter declaration requirements for methods annotated with @ReactPropGroup are different than for @ReactProp, please refer to the @ReactPropGroup annotation class docs for more information about it.

IMPORTANT! in ReactJS updating the property value will result in setter method call. Note that one of the ways we can update component is by removing properties that has been set before. In that case setter method will be called as well to notify view manager that property has changed. In that case "default" value will be provided (for primitive types "default" can value can be specified using defaultBoolean, defaultFloat, etc. arguments of @ReactProp annotation, for complex types setter will be called with value set to null).

@ReactProp(name = "src") - public void setSrc(ReactImageView view, @Nullable String src) { - view.setSource(src); + public void setSrc(ReactImageView view, @Nullable ReadableArray sources) { + view.setSource(sources); } @ReactProp(name = "borderRadius", defaultFloat = 0f)