From ed034c640a0e7f4a740fa99ce24f54526db50638 Mon Sep 17 00:00:00 2001 From: "Belde, Vikram" Date: Wed, 19 Oct 2016 23:41:49 -0400 Subject: [PATCH 1/2] React Upgrade and Syntax update --- Example/components/Error.js | 15 ++++++++++----- Example/components/Home.js | 15 ++++++++++----- Example/components/Launch.js | 24 +++++++++++++++++------- Example/components/Login.js | 16 +++++++++++----- Example/components/NavBar.js | 11 ++++++++--- Example/components/Register.js | 15 ++++++++++----- Example/index.ios.js | 21 +++++++++++++-------- 7 files changed, 79 insertions(+), 38 deletions(-) diff --git a/Example/components/Error.js b/Example/components/Error.js index 1476eab..2053d23 100644 --- a/Example/components/Error.js +++ b/Example/components/Error.js @@ -1,10 +1,15 @@ 'use strict'; -var React = require('react-native'); -var {View, Text, StyleSheet} = React; -var Button = require('react-native-button'); +import React, { Component } from 'react'; +import { + AppRegistry, + StyleSheet, + Text, + View +} from 'react-native'; +import Button from 'react-native-button' -class Error extends React.Component { +class Error extends Component { render(){ let Actions = this.props.routes; return ( @@ -18,4 +23,4 @@ class Error extends React.Component { } -module.exports = Error; \ No newline at end of file +module.exports = Error; diff --git a/Example/components/Home.js b/Example/components/Home.js index 8fda394..ff94efb 100644 --- a/Example/components/Home.js +++ b/Example/components/Home.js @@ -1,10 +1,15 @@ 'use strict'; -var React = require('react-native'); -var {View, Text, StyleSheet} = React; -var Button = require('react-native-button'); +import React, { Component } from 'react'; +import { + AppRegistry, + StyleSheet, + Text, + View +} from 'react-native'; +import Button from 'react-native-button' -class Register extends React.Component { +class Register extends Component { render(){ let Actions = this.props.routes; return ( @@ -35,4 +40,4 @@ var styles = StyleSheet.create({ }, }); -module.exports = Register; \ No newline at end of file +module.exports = Register; diff --git a/Example/components/Launch.js b/Example/components/Launch.js index 830761a..55e97f1 100644 --- a/Example/components/Launch.js +++ b/Example/components/Launch.js @@ -1,19 +1,29 @@ 'use strict'; -var React = require('react-native'); -var {View, Text, StyleSheet, TouchableHighlight} = React; -var Button = require('react-native-button'); +import React, { Component } from 'react'; +import { + AppRegistry, + StyleSheet, + Text, + View, + TouchableHighlight +} from 'react-native'; +import Button from 'react-native-button' -class Launch extends React.Component { +class Launch extends Component { render(){ var Actions = this.props.routes; return ( Launch page - - + Actions.login({data:"Custom data", title:'Custom title' })}> + + Click + + + {/* - + */} ); } diff --git a/Example/components/Login.js b/Example/components/Login.js index ed810e0..498adf2 100644 --- a/Example/components/Login.js +++ b/Example/components/Login.js @@ -1,10 +1,16 @@ 'use strict'; -var React = require('react-native'); -var {View, Text, StyleSheet} = React; -var Button = require('react-native-button'); +import React, { Component } from 'react'; +import { + AppRegistry, + StyleSheet, + Text, + View +} from 'react-native'; -class Login extends React.Component { +import Button from 'react-native-button' + +class Login extends Component { render(){ let Actions = this.props.routes; @@ -38,4 +44,4 @@ var styles = StyleSheet.create({ -module.exports = Login; \ No newline at end of file +module.exports = Login; diff --git a/Example/components/NavBar.js b/Example/components/NavBar.js index 0bdcc35..db24609 100644 --- a/Example/components/NavBar.js +++ b/Example/components/NavBar.js @@ -1,11 +1,16 @@ 'use strict'; var NavigationBar = require('react-native-navbar'); -var React = require('react-native'); -var {StyleSheet,View} = React; +import React, { Component } from 'react'; +import { + AppRegistry, + StyleSheet, + Text, + View +} from 'react-native'; var {Router, Route, Animations, Schema} = require('react-native-redux-router'); -class NavBarBase extends React.Component { +class NavBarBase extends Component { onPrev(){ var Actions = this.props.routes; if (this.props.onPrev){ diff --git a/Example/components/Register.js b/Example/components/Register.js index fbb6237..6626488 100644 --- a/Example/components/Register.js +++ b/Example/components/Register.js @@ -1,10 +1,15 @@ 'use strict'; -var React = require('react-native'); -var {View, Text, StyleSheet} = React; -var Button = require('react-native-button'); +import React, { Component } from 'react'; +import { + AppRegistry, + StyleSheet, + Text, + View +} from 'react-native'; +import Button from 'react-native-button' -class Register extends React.Component { +class Register extends Component { render(){ let Actions = this.props.routes; return ( @@ -36,4 +41,4 @@ var styles = StyleSheet.create({ }, }); -module.exports = Register; \ No newline at end of file +module.exports = Register; diff --git a/Example/index.ios.js b/Example/index.ios.js index e0f1813..0a18a4c 100644 --- a/Example/index.ios.js +++ b/Example/index.ios.js @@ -1,7 +1,12 @@ 'use strict'; -var React = require('react-native'); -var {AppRegistry, StyleSheet,Text,View} = React; +import React, { Component } from 'react'; +import { + AppRegistry, + StyleSheet, + Text, + View +} from 'react-native'; var Launch = require('./components/Launch'); var Register = require('./components/Register'); var Login = require('./components/Login'); @@ -11,7 +16,7 @@ var Error = require('./components/Error'); var Home = require('./components/Home'); import { createStore, combineReducers, applyMiddleware } from 'redux'; -import { Provider } from 'react-redux/native'; +import { Provider } from 'react-redux'; import createLogger from 'redux-logger'; const loggerMiddleWare = createLogger(); @@ -20,7 +25,7 @@ const createStoreWithMiddleware = applyMiddleware(loggerMiddleWare)(createStore) const reducer = combineReducers({routerReducer}); let store = createStoreWithMiddleware(reducer); -class App extends React.Component { +class App extends Component { render(){ return ( @@ -43,12 +48,12 @@ class App extends React.Component { ); } } -class Example extends React.Component { +class Example extends Component { render() { return ( - - {() => } - + + + ); } } From f69839738f685e8fe8a12fdae272376ff036f70a Mon Sep 17 00:00:00 2001 From: "Belde, Vikram" Date: Wed, 19 Oct 2016 23:54:35 -0400 Subject: [PATCH 2/2] revert to Example Code --- Example/components/Launch.js | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/Example/components/Launch.js b/Example/components/Launch.js index 55e97f1..176a50d 100644 --- a/Example/components/Launch.js +++ b/Example/components/Launch.js @@ -16,14 +16,10 @@ class Launch extends Component { return ( Launch page - Actions.login({data:"Custom data", title:'Custom title' })}> - - Click - - - {/* + + - */} + ); }