mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-02-11 17:21:11 +08:00
replace require with es6 import in docs
Reviewed By: svcscm Differential Revision: D2936839 fb-gh-sync-id: 7a921709a37de5e9aadf324d5438d51851326348 shipit-source-id: 7a921709a37de5e9aadf324d5438d51851326348
This commit is contained in:
committed by
facebook-github-bot-7
parent
2260d900d4
commit
3ae99d0fea
@@ -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 argument of the setter. The following type of values are currently supported: `boolean`, `int`, `float`, `double`, `String`, `Boolean`, `Integer`, `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 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.
|
||||
|
||||
@@ -72,12 +72,12 @@ Setter declaration requirements for methods annotated with `@ReactPropGroup` are
|
||||
public void setSrc(ReactImageView view, @Nullable String src) {
|
||||
view.setSource(src);
|
||||
}
|
||||
|
||||
|
||||
@ReactProp(name = "borderRadius", defaultFloat = 0f)
|
||||
public void setBorderRadius(ReactImageView view, float borderRadius) {
|
||||
view.setBorderRadius(borderRadius);
|
||||
}
|
||||
|
||||
|
||||
@ReactProp(name = ViewProps.RESIZE_MODE)
|
||||
public void setResizeMode(ReactImageView view, @Nullable String resizeMode) {
|
||||
view.setScaleType(ImageResizeMode.toScaleType(resizeMode));
|
||||
@@ -105,7 +105,7 @@ The very final step is to create the JavaScript module that defines the interfac
|
||||
```js
|
||||
// ImageView.js
|
||||
|
||||
var { requireNativeComponent, PropTypes } = require('react-native');
|
||||
import { requireNativeComponent, PropTypes } from 'react-native';
|
||||
|
||||
var iface = {
|
||||
name: 'ImageView',
|
||||
|
||||
Reference in New Issue
Block a user