Convert Example app to use ES6 import syntax

This commit is contained in:
Scott Kyle 2016-02-15 15:03:16 -08:00
parent 0188517e74
commit 2bdb6bfa28
10 changed files with 57 additions and 54 deletions

View File

@ -6,10 +6,12 @@
"ecmaFeatures": {
"jsx": true
},
"parser": "babel-eslint",
"plugins": [
"react"
],
"rules": {
"strict": 0,
"react/jsx-no-duplicate-props": 2,
"react/jsx-no-undef": 2,
"react/jsx-uses-react": 2,

View File

@ -4,9 +4,9 @@
'use strict';
const Realm = require('realm');
import Realm from 'realm';
module.exports = new Realm({
export default new Realm({
schema: [
{
name: 'Todo',

View File

@ -4,14 +4,16 @@
'use strict';
const React = require('react-native');
import {
Navigator,
Platform,
StyleSheet
} from 'react-native';
const { Navigator, Platform, StyleSheet } = React;
const { NavBarHeight, TotalNavHeight } = Navigator.NavigationBar.Styles.General;
const iOS = (Platform.OS == 'ios');
module.exports = StyleSheet.create({
export default StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',

View File

@ -4,21 +4,21 @@
'use strict';
const React = require('react-native');
const TodoItem = require('./todo-item');
const TodoListView = require('./todo-listview');
const realm = require('./realm');
const styles = require('./styles');
const {
import React, {
Component,
Navigator,
StatusBarIOS,
Text,
TouchableOpacity,
View,
} = React;
} from 'react-native';
class TodoApp extends React.Component {
import TodoItem from './todo-item';
import TodoListView from './todo-listview';
import realm from './realm';
import styles from './styles';
export default class TodoApp extends Component {
constructor(props) {
super(props);
@ -203,5 +203,3 @@ const RouteMapper = {
);
},
};
module.exports = TodoApp;

View File

@ -4,14 +4,17 @@
'use strict';
const React = require('react-native');
const TodoListItem = require('./todo-list-item');
const realm = require('./realm');
const styles = require('./styles');
import React, {
Text,
TouchableWithoutFeedback,
View,
} from 'react-native';
const { Text, TouchableWithoutFeedback, View } = React;
import TodoListItem from './todo-list-item';
import realm from './realm';
import styles from './styles';
class TodoItem extends TodoListItem {
export default class TodoItem extends TodoListItem {
constructor(props) {
super(props);
@ -56,5 +59,3 @@ class TodoItem extends TodoListItem {
this.forceUpdate();
}
}
module.exports = TodoItem;

View File

@ -4,21 +4,20 @@
'use strict';
const React = require('react-native');
const realm = require('./realm');
const styles = require('./styles');
const {
import React, {
Platform,
Text,
TextInput,
TouchableWithoutFeedback,
View,
} = React;
} from 'react-native';
import realm from './realm';
import styles from './styles';
const iOS = (Platform.OS == 'ios');
class TodoListItem extends React.Component {
export default class TodoListItem extends React.Component {
constructor(props) {
super(props);
@ -123,5 +122,3 @@ class TodoListItem extends React.Component {
}
}
}
module.exports = TodoListItem;

View File

@ -4,16 +4,17 @@
'use strict';
const React = require('react-native');
const RealmReact = require('realm/react-native');
const TodoListItem = require('./todo-list-item');
const realm = require('./realm');
const styles = require('./styles');
import React, {
Text,
View,
} from 'react-native';
const { Text, View } = React;
const { ListView } = RealmReact;
import { ListView } from 'realm/react-native';
import TodoListItem from './todo-list-item';
import realm from './realm';
import styles from './styles';
class TodoListView extends React.Component {
export default class TodoListView extends React.Component {
constructor(props) {
super(props);
@ -175,5 +176,3 @@ class TodoListExtraItem extends TodoListItem {
return null;
}
}
module.exports = TodoListView;

View File

@ -1,10 +1,7 @@
/* Copyright 2015 Realm Inc - All Rights Reserved
/* Copyright 2016 Realm Inc - All Rights Reserved
* Proprietary and Confidential
*/
'use strict';
const React = require('react-native');
const TodoApp = require('./components/todo-app');
React.AppRegistry.registerComponent('ReactExample', () => TodoApp);
import './main';

View File

@ -1,10 +1,7 @@
/* Copyright 2015 Realm Inc - All Rights Reserved
/* Copyright 2016 Realm Inc - All Rights Reserved
* Proprietary and Confidential
*/
'use strict';
const React = require('react-native');
const TodoApp = require('./components/todo-app');
React.AppRegistry.registerComponent('ReactExample', () => TodoApp);
import './main';

View File

@ -0,0 +1,10 @@
/* Copyright 2016 Realm Inc - All Rights Reserved
* Proprietary and Confidential
*/
'use strict';
import { AppRegistry } from 'react-native';
import TodoApp from './components/todo-app';
AppRegistry.registerComponent('ReactExample', () => TodoApp);