mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Convert from React.createClass to ES6 classes
Reviewed By: cpojer Differential Revision: D3619143 fbshipit-source-id: e14e81468d467437ee3d79c34c34b7780a46ca1c
This commit is contained in:
committed by
Facebook Github Bot 8
parent
857d2b8eae
commit
a2fb703bbb
@@ -33,26 +33,22 @@ const {
|
||||
Text,
|
||||
TouchableWithoutFeedback,
|
||||
} = ReactNative;
|
||||
// $FlowFixMe found when converting React.createClass to ES6
|
||||
const Item = Picker.Item;
|
||||
|
||||
const PickerExample = React.createClass({
|
||||
class PickerExample extends React.Component {
|
||||
static title = '<Picker>';
|
||||
static description = 'Provides multiple options to choose from, using either a dropdown menu or a dialog.';
|
||||
|
||||
statics: {
|
||||
title: '<Picker>',
|
||||
description: 'Provides multiple options to choose from, using either a dropdown menu or a dialog.',
|
||||
},
|
||||
state = {
|
||||
selected1: 'key1',
|
||||
selected2: 'key1',
|
||||
selected3: 'key1',
|
||||
color: 'red',
|
||||
mode: Picker.MODE_DIALOG,
|
||||
};
|
||||
|
||||
getInitialState: function() {
|
||||
return {
|
||||
selected1: 'key1',
|
||||
selected2: 'key1',
|
||||
selected3: 'key1',
|
||||
color: 'red',
|
||||
mode: Picker.MODE_DIALOG,
|
||||
};
|
||||
},
|
||||
|
||||
render: function() {
|
||||
render() {
|
||||
return (
|
||||
<UIExplorerPage title="<Picker>">
|
||||
<UIExplorerBlock title="Basic Picker">
|
||||
@@ -121,21 +117,21 @@ const PickerExample = React.createClass({
|
||||
</UIExplorerBlock>
|
||||
</UIExplorerPage>
|
||||
);
|
||||
},
|
||||
}
|
||||
|
||||
changeMode: function() {
|
||||
changeMode = () => {
|
||||
const newMode = this.state.mode === Picker.MODE_DIALOG
|
||||
? Picker.MODE_DROPDOWN
|
||||
: Picker.MODE_DIALOG;
|
||||
this.setState({mode: newMode});
|
||||
},
|
||||
};
|
||||
|
||||
onValueChange: function(key: string, value: string) {
|
||||
onValueChange = (key: string, value: string) => {
|
||||
const newState = {};
|
||||
newState[key] = value;
|
||||
this.setState(newState);
|
||||
},
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
var styles = StyleSheet.create({
|
||||
picker: {
|
||||
|
||||
Reference in New Issue
Block a user