Document default values for @ReactProp

This commit is contained in:
Krzysztof Magiera 2015-10-28 20:48:14 +00:00
parent 0b9c704544
commit 830b46ea43
1 changed files with 3 additions and 1 deletions

View File

@ -57,7 +57,7 @@ Views are created in the `createViewInstance` method, the view should initialize
## 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 argumen of the setter. The following type of values are currently supported: `boolean`, `int`, `float`, `double`, `String`, `ReadableArray`, `ReadableMap`.
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 argumen 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.
@ -65,6 +65,8 @@ Except from `name`, `@ReactProp` annotation may take following optional argument
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`).
```java
@ReactProp(name = "src")
public void setSrc(ReactImageView view, @Nullable String src) {