Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions docs/Animations.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ component with a simple spring bounce on mount looks like this:

```javascript
class Playground extends React.Component {
constructor(props: any) {
constructor(props) {
super(props);
this.state = {
bounceValue: new Animated.Value(0),
};
}
render(): ReactElement {
render() {
return (
<Animated.Image // Base: Image, Text, View
source={{uri: 'http://i.imgur.com/XMKOH81.jpg'}}
Expand Down Expand Up @@ -286,7 +286,7 @@ class App extends React.Component {
componentWillMount() {
// Animate creation
LayoutAnimation.spring();
},
}

_onPress() {
// Animate the update
Expand All @@ -306,7 +306,7 @@ class App extends React.Component {
</View>
);
}
};
}
```
[Run this example](https://rnplay.org/apps/uaQrGQ)

Expand Down
40 changes: 23 additions & 17 deletions docs/DirectManipulation.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ uses `setNativeProps` internally to update the opacity of its child
component:

```javascript
setOpacityTo: function(value) {
setOpacityTo(value) {
// Redacted: animation related code
this.refs[CHILD_REF].setNativeProps({
opacity: value
Expand All @@ -57,9 +57,10 @@ might implement it with that constraint is to store the opacity value
in the state, then update that value whenever `onPress` is fired:

```javascript
getInitialState() {
return { myButtonOpacity: 1, }
},
constructor(props) {
super(props);
this.state = { myButtonOpacity: 1, };
}

render() {
return (
Expand Down Expand Up @@ -93,25 +94,25 @@ Composite components are not backed by a native view, so you cannot call
`setNativeProps` on them. Consider this example:

```javascript
var MyButton = React.createClass({
class MyButton extends React.Component {
render() {
return (
<View>
<Text>{this.props.label}</Text>
</View>
)
},
});
}
}

var App = React.createClass({
class App extends React.Component {
render() {
return (
<TouchableOpacity>
<MyButton label="Press me!" />
</TouchableOpacity>
)
},
});
}
}
```
[Run this example](https://rnplay.org/apps/JXkgmQ)

Expand All @@ -132,19 +133,19 @@ that calls `setNativeProps` on the appropriate child with the given
arguments.

```javascript
var MyButton = React.createClass({
class MyButton extends React.Component {
setNativeProps(nativeProps) {
this._root.setNativeProps(nativeProps);
},
}

render() {
return (
<View ref={component => this._root = component} {...this.props}>
<Text>{this.props.label}</Text>
</View>
)
},
});
}
}
```
[Run this example](https://rnplay.org/apps/YJxnEQ)

Expand Down Expand Up @@ -172,10 +173,15 @@ necessary. For example, the following code demonstrates clearing the
input when you tap a button:

```javascript
var App = React.createClass({
class App extends React.Component {
constructor(props) {
super(props);
this.clearText = this.clearText.bind(this);
}

clearText() {
this._textInput.setNativeProps({text: ''});
},
}

render() {
return (
Expand All @@ -188,7 +194,7 @@ var App = React.createClass({
</View>
);
}
});
}
```
[Run this example](https://rnplay.org/plays/pOI9bA)

Expand Down
3 changes: 2 additions & 1 deletion docs/NativeComponentsAndroid.md
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,8 @@ The event name `topChange` maps to the `onChange` callback prop in JavaScript (m
// MyCustomView.js

class MyCustomView extends React.Component {
constructor() {
constructor(props) {
super(props);
this._onChange = this._onChange.bind(this);
}
_onChange(event: Event) {
Expand Down