Skip to content

Commit

Permalink
Convert from React.createClass to ES6 classes
Browse files Browse the repository at this point in the history
Reviewed By: cpojer

Differential Revision: D3619143

fbshipit-source-id: e14e81468d467437ee3d79c34c34b7780a46ca1c
  • Loading branch information
sophiebits authored and Facebook Github Bot 8 committed Jul 26, 2016
1 parent 857d2b8 commit a2fb703
Show file tree
Hide file tree
Showing 133 changed files with 2,125 additions and 2,192 deletions.
6 changes: 3 additions & 3 deletions Examples/Movies/MovieCell.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ var getStyleFromScore = require('./getStyleFromScore');
var getImageSource = require('./getImageSource');
var getTextFromScore = require('./getTextFromScore');

var MovieCell = React.createClass({
render: function() {
class MovieCell extends React.Component {
render() {
var criticsScore = this.props.movie.ratings.critics_score;
var TouchableElement = TouchableHighlight;
if (Platform.OS === 'android') {
Expand Down Expand Up @@ -66,7 +66,7 @@ var MovieCell = React.createClass({
</View>
);
}
});
}

var styles = StyleSheet.create({
textContainer: {
Expand Down
24 changes: 12 additions & 12 deletions Examples/Movies/MovieScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ var getImageSource = require('./getImageSource');
var getStyleFromScore = require('./getStyleFromScore');
var getTextFromScore = require('./getTextFromScore');

var MovieScreen = React.createClass({
render: function() {
class MovieScreen extends React.Component {
render() {
return (
<ScrollView contentContainerStyle={styles.contentContainer}>
<View style={styles.mainSection}>
Expand All @@ -57,11 +57,11 @@ var MovieScreen = React.createClass({
<Cast actors={this.props.movie.abridged_cast} />
</ScrollView>
);
},
});
}
}

var Ratings = React.createClass({
render: function() {
class Ratings extends React.Component {
render() {
var criticsScore = this.props.ratings.critics_score;
var audienceScore = this.props.ratings.audience_score;

Expand All @@ -81,11 +81,11 @@ var Ratings = React.createClass({
</View>
</View>
);
},
});
}
}

var Cast = React.createClass({
render: function() {
class Cast extends React.Component {
render() {
if (!this.props.actors) {
return null;
}
Expand All @@ -100,8 +100,8 @@ var Cast = React.createClass({
)}
</View>
);
},
});
}
}

var styles = StyleSheet.create({
contentContainer: {
Expand Down
6 changes: 3 additions & 3 deletions Examples/Movies/MoviesApp.android.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ var RouteMapper = function(route, navigationOperations, onComponentRef) {
}
};

var MoviesApp = React.createClass({
render: function() {
class MoviesApp extends React.Component {
render() {
var initialRoute = {name: 'search'};
return (
<Navigator
Expand All @@ -77,7 +77,7 @@ var MoviesApp = React.createClass({
/>
);
}
});
}

var styles = StyleSheet.create({
container: {
Expand Down
6 changes: 3 additions & 3 deletions Examples/Movies/MoviesApp.ios.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ var {

var SearchScreen = require('./SearchScreen');

var MoviesApp = React.createClass({
render: function() {
class MoviesApp extends React.Component {
render() {
return (
<NavigatorIOS
style={styles.container}
Expand All @@ -38,7 +38,7 @@ var MoviesApp = React.createClass({
/>
);
}
});
}

var styles = StyleSheet.create({
container: {
Expand Down
6 changes: 3 additions & 3 deletions Examples/Movies/SearchBar.android.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ var {

var IS_RIPPLE_EFFECT_SUPPORTED = Platform.Version >= 21;

var SearchBar = React.createClass({
render: function() {
class SearchBar extends React.Component {
render() {
var background = IS_RIPPLE_EFFECT_SUPPORTED ?
TouchableNativeFeedback.SelectableBackgroundBorderless() :
TouchableNativeFeedback.SelectableBackground();
Expand Down Expand Up @@ -67,7 +67,7 @@ var SearchBar = React.createClass({
</View>
);
}
});
}

var styles = StyleSheet.create({
searchBar: {
Expand Down
6 changes: 3 additions & 3 deletions Examples/Movies/SearchBar.ios.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ var {
View,
} = ReactNative;

var SearchBar = React.createClass({
render: function() {
class SearchBar extends React.Component {
render() {
return (
<View style={styles.searchBar}>
<TextInput
Expand All @@ -44,7 +44,7 @@ var SearchBar = React.createClass({
</View>
);
}
});
}

var styles = StyleSheet.create({
searchBar: {
Expand Down
6 changes: 3 additions & 3 deletions Examples/Movies/SearchScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -318,8 +318,8 @@ var SearchScreen = React.createClass({
},
});

var NoMovies = React.createClass({
render: function() {
class NoMovies extends React.Component {
render() {
var text = '';
if (this.props.filter) {
text = `No results for "${this.props.filter}"`;
Expand All @@ -335,7 +335,7 @@ var NoMovies = React.createClass({
</View>
);
}
});
}

var styles = StyleSheet.create({
container: {
Expand Down
20 changes: 10 additions & 10 deletions Examples/TicTacToe/TicTacToeApp.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@ class Board {
}
}

var Cell = React.createClass({
cellStyle() {
class Cell extends React.Component {
cellStyle = () => {
switch (this.props.player) {
case 1:
return styles.cellX;
Expand All @@ -104,9 +104,9 @@ var Cell = React.createClass({
default:
return null;
}
},
};

textStyle() {
textStyle = () => {
switch (this.props.player) {
case 1:
return styles.cellTextX;
Expand All @@ -115,9 +115,9 @@ var Cell = React.createClass({
default:
return {};
}
},
};

textContents() {
textContents = () => {
switch (this.props.player) {
case 1:
return 'X';
Expand All @@ -126,7 +126,7 @@ var Cell = React.createClass({
default:
return '';
}
},
};

render() {
return (
Expand All @@ -142,9 +142,9 @@ var Cell = React.createClass({
</TouchableHighlight>
);
}
});
}

var GameEndOverlay = React.createClass({
class GameEndOverlay extends React.Component {
render() {
var board = this.props.board;

Expand Down Expand Up @@ -175,7 +175,7 @@ var GameEndOverlay = React.createClass({
</View>
);
}
});
}

var TicTacToeApp = React.createClass({
getInitialState() {
Expand Down
39 changes: 17 additions & 22 deletions Examples/UIExplorer/js/AccessibilityAndroidExample.android.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,40 +36,35 @@ var UIExplorerPage = require('./UIExplorerPage');

var importantForAccessibilityValues = ['auto', 'yes', 'no', 'no-hide-descendants'];

var AccessibilityAndroidExample = React.createClass({
class AccessibilityAndroidExample extends React.Component {
static title = 'Accessibility';
static description = 'Examples of using Accessibility API.';

statics: {
title: 'Accessibility',
description: 'Examples of using Accessibility API.',
},

getInitialState: function() {
return {
count: 0,
backgroundImportantForAcc: 0,
forgroundImportantForAcc: 0,
};
},
state = {
count: 0,
backgroundImportantForAcc: 0,
forgroundImportantForAcc: 0,
};

_addOne: function() {
_addOne = () => {
this.setState({
count: ++this.state.count,
});
},
};

_changeBackgroundImportantForAcc: function() {
_changeBackgroundImportantForAcc = () => {
this.setState({
backgroundImportantForAcc: (this.state.backgroundImportantForAcc + 1) % 4,
});
},
};

_changeForgroundImportantForAcc: function() {
_changeForgroundImportantForAcc = () => {
this.setState({
forgroundImportantForAcc: (this.state.forgroundImportantForAcc + 1) % 4,
});
},
};

render: function() {
render() {
return (
<UIExplorerPage title={'Accessibility'}>

Expand Down Expand Up @@ -202,8 +197,8 @@ var AccessibilityAndroidExample = React.createClass({

</UIExplorerPage>
);
},
});
}
}

var styles = StyleSheet.create({
embedded: {
Expand Down
6 changes: 3 additions & 3 deletions Examples/UIExplorer/js/AccessibilityIOSExample.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ var {
View,
} = ReactNative;

var AccessibilityIOSExample = React.createClass({
class AccessibilityIOSExample extends React.Component {
render() {
return (
<View>
Expand Down Expand Up @@ -60,8 +60,8 @@ var AccessibilityIOSExample = React.createClass({
</View>
</View>
);
},
});
}
}

exports.title = 'AccessibilityIOS';
exports.description = 'Interface to show iOS\' accessibility samples';
Expand Down
Loading

0 comments on commit a2fb703

Please sign in to comment.