diff --git a/docs/docs/02-displaying-data.md b/docs/docs/02-displaying-data.md
index f9158275e0..70ad425add 100644
--- a/docs/docs/02-displaying-data.md
+++ b/docs/docs/02-displaying-data.md
@@ -36,8 +36,8 @@ Let's look at a really simple example. Create a `hello-react.html` file with the
For the rest of the documentation, we'll just focus on the JavaScript code and assume it's inserted into a template like the one above. Replace the placeholder comment above with the following JSX:
```javascript
-var HelloWorld = React.createClass({
- render: function() {
+class HelloWorld extends React.Component {
+ render() {
return (
Hello, !
@@ -45,14 +45,16 @@ var HelloWorld = React.createClass({
);
}
-});
+}
-setInterval(function() {
+function tick() {
ReactDOM.render(
,
document.getElementById('example')
);
-}, 500);
+}
+
+setInterval(tick, 500);
```
## Reactive Updates
diff --git a/docs/docs/04-multiple-components.md b/docs/docs/04-multiple-components.md
index 24323a9cf1..c74476779a 100644
--- a/docs/docs/04-multiple-components.md
+++ b/docs/docs/04-multiple-components.md
@@ -17,8 +17,8 @@ By building modular components that reuse other components with well-defined int
Let's create a simple Avatar component which shows a Facebook page picture and name using the Facebook Graph API.
```javascript
-var Avatar = React.createClass({
- render: function() {
+class Avatar extends React.Component {
+ render() {
return (
@@ -26,25 +26,25 @@ var Avatar = React.createClass({
);
}
-});
+}
-var PagePic = React.createClass({
- render: function() {
+class PagePic extends React.Component {
+ render() {
return (
);
}
-});
+}
-var PageLink = React.createClass({
- render: function() {
+class PageLink extends React.Component {
+ render() {
return (
{this.props.pagename}
);
}
-});
+}
ReactDOM.render(
,
@@ -110,13 +110,12 @@ In most cases, this can be sidestepped by hiding elements instead of destroying
The situation gets more complicated when the children are shuffled around (as in search results) or if new components are added onto the front of the list (as in streams). In these cases where the identity and state of each child must be maintained across render passes, you can uniquely identify each child by assigning it a `key`:
```javascript
- render: function() {
- var results = this.props.results;
+ render() {
return (
- {results.map(function(result) {
- return
{result.text}
;
- })}
+ {this.props.results.map((result) => (
+
{result.text}
+ ))}
);
}
@@ -128,41 +127,41 @@ The `key` should *always* be supplied directly to the components in the array, n
```javascript
// WRONG!
-var ListItemWrapper = React.createClass({
- render: function() {
+class ListItemWrapper extends React.Component {
+ render() {
return