diff --git a/examples/ReactExample/.eslintrc b/examples/ReactExample/.eslintrc index 98b5f8ba..44bd6ec5 100644 --- a/examples/ReactExample/.eslintrc +++ b/examples/ReactExample/.eslintrc @@ -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, diff --git a/examples/ReactExample/components/realm.js b/examples/ReactExample/components/realm.js index d3f44bed..6640e717 100644 --- a/examples/ReactExample/components/realm.js +++ b/examples/ReactExample/components/realm.js @@ -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', diff --git a/examples/ReactExample/components/styles.js b/examples/ReactExample/components/styles.js index 9ab48593..b8807129 100644 --- a/examples/ReactExample/components/styles.js +++ b/examples/ReactExample/components/styles.js @@ -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', diff --git a/examples/ReactExample/components/todo-app.js b/examples/ReactExample/components/todo-app.js index 04711335..375163ae 100644 --- a/examples/ReactExample/components/todo-app.js +++ b/examples/ReactExample/components/todo-app.js @@ -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; diff --git a/examples/ReactExample/components/todo-item.js b/examples/ReactExample/components/todo-item.js index b8306d73..76b8c572 100644 --- a/examples/ReactExample/components/todo-item.js +++ b/examples/ReactExample/components/todo-item.js @@ -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; diff --git a/examples/ReactExample/components/todo-list-item.js b/examples/ReactExample/components/todo-list-item.js index ac82b878..fe4e43f0 100644 --- a/examples/ReactExample/components/todo-list-item.js +++ b/examples/ReactExample/components/todo-list-item.js @@ -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; diff --git a/examples/ReactExample/components/todo-listview.js b/examples/ReactExample/components/todo-listview.js index 14c3057a..ad4f2945 100644 --- a/examples/ReactExample/components/todo-listview.js +++ b/examples/ReactExample/components/todo-listview.js @@ -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; diff --git a/examples/ReactExample/index.android.js b/examples/ReactExample/index.android.js index c506bc04..77d06c34 100644 --- a/examples/ReactExample/index.android.js +++ b/examples/ReactExample/index.android.js @@ -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'; diff --git a/examples/ReactExample/index.ios.js b/examples/ReactExample/index.ios.js index c506bc04..77d06c34 100644 --- a/examples/ReactExample/index.ios.js +++ b/examples/ReactExample/index.ios.js @@ -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'; diff --git a/examples/ReactExample/main.js b/examples/ReactExample/main.js new file mode 100644 index 00000000..693f6378 --- /dev/null +++ b/examples/ReactExample/main.js @@ -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);