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": { "ecmaFeatures": {
"jsx": true "jsx": true
}, },
"parser": "babel-eslint",
"plugins": [ "plugins": [
"react" "react"
], ],
"rules": { "rules": {
"strict": 0,
"react/jsx-no-duplicate-props": 2, "react/jsx-no-duplicate-props": 2,
"react/jsx-no-undef": 2, "react/jsx-no-undef": 2,
"react/jsx-uses-react": 2, "react/jsx-uses-react": 2,

View File

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

View File

@ -4,14 +4,16 @@
'use strict'; '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 { NavBarHeight, TotalNavHeight } = Navigator.NavigationBar.Styles.General;
const iOS = (Platform.OS == 'ios'); const iOS = (Platform.OS == 'ios');
module.exports = StyleSheet.create({ export default StyleSheet.create({
container: { container: {
flex: 1, flex: 1,
justifyContent: 'center', justifyContent: 'center',

View File

@ -4,21 +4,21 @@
'use strict'; 'use strict';
const React = require('react-native'); import React, {
const TodoItem = require('./todo-item'); Component,
const TodoListView = require('./todo-listview');
const realm = require('./realm');
const styles = require('./styles');
const {
Navigator, Navigator,
StatusBarIOS, StatusBarIOS,
Text, Text,
TouchableOpacity, TouchableOpacity,
View, 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) { constructor(props) {
super(props); super(props);
@ -203,5 +203,3 @@ const RouteMapper = {
); );
}, },
}; };
module.exports = TodoApp;

View File

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

View File

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

View File

@ -4,16 +4,17 @@
'use strict'; 'use strict';
const React = require('react-native'); import React, {
const RealmReact = require('realm/react-native'); Text,
const TodoListItem = require('./todo-list-item'); View,
const realm = require('./realm'); } from 'react-native';
const styles = require('./styles');
const { Text, View } = React; import { ListView } from 'realm/react-native';
const { ListView } = RealmReact; 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) { constructor(props) {
super(props); super(props);
@ -175,5 +176,3 @@ class TodoListExtraItem extends TodoListItem {
return null; 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 * Proprietary and Confidential
*/ */
'use strict'; 'use strict';
const React = require('react-native'); import './main';
const TodoApp = require('./components/todo-app');
React.AppRegistry.registerComponent('ReactExample', () => TodoApp);

View File

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

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);