mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-04-29 04:35:36 +08:00
Fix incorrect code sample
getInitialState and componentDidMount were nested inside the render method.
This commit is contained in:
18
website/src/react-native/index.js
vendored
18
website/src/react-native/index.js
vendored
@@ -187,19 +187,19 @@ var React = require('react-native');
|
|||||||
var { NativeModules, Text } = React;
|
var { NativeModules, Text } = React;
|
||||||
|
|
||||||
var Message = React.createClass({
|
var Message = React.createClass({
|
||||||
|
getInitialState() {
|
||||||
|
return { text: 'Goodbye World.' };
|
||||||
|
},
|
||||||
|
componentDidMount() {
|
||||||
|
NativeModules.MyCustomModule.processString(this.state.text, (text) => {
|
||||||
|
this.setState({text});
|
||||||
|
});
|
||||||
|
},
|
||||||
render: function() {
|
render: function() {
|
||||||
getInitialState() {
|
|
||||||
return { text: 'Goodbye World.' };
|
|
||||||
},
|
|
||||||
componentDidMount() {
|
|
||||||
NativeModules.MyCustomModule.processString(this.state.text, (text) => {
|
|
||||||
this.setState({text});
|
|
||||||
});
|
|
||||||
},
|
|
||||||
return (
|
return (
|
||||||
<Text>{this.state.text}</Text>
|
<Text>{this.state.text}</Text>
|
||||||
);
|
);
|
||||||
},
|
}
|
||||||
});`}
|
});`}
|
||||||
</Prism>
|
</Prism>
|
||||||
<p>
|
<p>
|
||||||
|
|||||||
Reference in New Issue
Block a user