Updated docs for next

This commit is contained in:
Website Deployment Script
2017-07-31 11:09:35 +00:00
parent 662ac5b0f2
commit 02f734bdee
@@ -11,8 +11,8 @@
<span class="token keyword">public</span> ReactImageView <span class="token function">createViewInstance<span class="token punctuation">(</span></span>ThemedReactContext context<span class="token punctuation">)</span> <span class="token punctuation">{</span>
<span class="token keyword">return</span> <span class="token keyword">new</span> <span class="token class-name">ReactImageView</span><span class="token punctuation">(</span>context<span class="token punctuation">,</span> Fresco<span class="token punctuation">.</span><span class="token function">newDraweeControllerBuilder<span class="token punctuation">(</span></span><span class="token punctuation">)</span><span class="token punctuation">,</span> mCallerContext<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span></div><h2><a class="anchor" name="3-expose-view-property-setters-using-reactprop-or-reactpropgroup-annotation"></a>3. Expose view property setters using <code>@ReactProp</code> (or <code>@ReactPropGroup</code>) annotation <a class="hash-link" href="docs/native-components-android.html#3-expose-view-property-setters-using-reactprop-or-reactpropgroup-annotation">#</a></h2><p>Properties that are to be reflected in JavaScript needs to be exposed as setter method annotated with <code>@ReactProp</code> (or <code>@ReactPropGroup</code>). 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 <code>void</code> method and should be <code>public</code>. 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: <code>boolean</code>, <code>int</code>, <code>float</code>, <code>double</code>, <code>String</code>, <code>Boolean</code>, <code>Integer</code>, <code>ReadableArray</code>, <code>ReadableMap</code>.</p><p>Annotation <code>@ReactProp</code> has one obligatory argument <code>name</code> of type <code>String</code>. Name assigned to the <code>@ReactProp</code> annotation linked to the setter method is used to reference the property on JS side.</p><p>Except from <code>name</code>, <code>@ReactProp</code> annotation may take following optional arguments: <code>defaultBoolean</code>, <code>defaultInt</code>, <code>defaultFloat</code>. Those arguments should be of the corresponding primitive type (accordingly <code>boolean</code>, <code>int</code>, <code>float</code>) 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 &quot;default&quot; values are only provided for primitive types, in case when setter is of some complex type, <code>null</code> will be provided as a default value in case when corresponding property gets removed.</p><p>Setter declaration requirements for methods annotated with <code>@ReactPropGroup</code> are different than for <code>@ReactProp</code>, please refer to the <code>@ReactPropGroup</code> annotation class docs for more information about it.</p><p><strong>IMPORTANT!</strong> 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 &quot;default&quot; value will be provided (for primitive types &quot;default&quot; can value can be specified using <code>defaultBoolean</code>, <code>defaultFloat</code>, etc. arguments of <code>@ReactProp</code> annotation, for complex types setter will be called with value set to <code>null</code>).</p><div class="prism language-java"> @<span class="token function">ReactProp<span class="token punctuation">(</span></span>name <span class="token operator">=</span> <span class="token string">&quot;src&quot;</span><span class="token punctuation">)</span>
<span class="token keyword">public</span> <span class="token keyword">void</span> <span class="token function">setSrc<span class="token punctuation">(</span></span>ReactImageView view<span class="token punctuation">,</span> @Nullable String src<span class="token punctuation">)</span> <span class="token punctuation">{</span>
view<span class="token punctuation">.</span><span class="token function">setSource<span class="token punctuation">(</span></span>src<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">public</span> <span class="token keyword">void</span> <span class="token function">setSrc<span class="token punctuation">(</span></span>ReactImageView view<span class="token punctuation">,</span> @Nullable ReadableArray sources<span class="token punctuation">)</span> <span class="token punctuation">{</span>
view<span class="token punctuation">.</span><span class="token function">setSource<span class="token punctuation">(</span></span>sources<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>
@<span class="token function">ReactProp<span class="token punctuation">(</span></span>name <span class="token operator">=</span> <span class="token string">&quot;borderRadius&quot;</span><span class="token punctuation">,</span> defaultFloat <span class="token operator">=</span> <span class="token number">0f</span><span class="token punctuation">)</span>