Skip to content
This repository was archived by the owner on Apr 1, 2025. It is now read-only.

Conversation

rakeshM-Webonise
Copy link

No description provided.

import variable from './../variables/platform';

export default (variables /*: * */ = variable) => {
const bodyTheme = {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

directly return from here, no need to create variable.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Above code is in Native base theme third party Library.

@@ -0,0 +1,90 @@
// @flow
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can use file naming conventions for such fil as Form.style.js and for component Form.js

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Above code is in Native base theme third party Library.

@@ -0,0 +1,25 @@
var localDB ={
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be export localDB

</Text>
</View>
<View style={styles.menuItem}>
<Image source={{uri:'https://img.icons8.com/ios/60/000000/google-nearby.png'}}/>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

uri should be constant

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes has been done as per suggestions.


export default DrawerScreen;

const styles = StyleSheet.create({
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can move this to separate file DrawerScreen.style.js and export from there.
I recommend to create directory with name DrawerScreen under that all the files related to that will exist.
eg. DrawerScreen.jsx(component), DrawerScreen.test.js(test cases) & DrawerScreen.style.js(stylesheets)

@@ -0,0 +1,116 @@
import React from "react";
import { FlatList, StyleSheet, Text, View, Image } from "react-native";
import { Button } from "react-native-elements";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

combine 2 imports

};

componentWillMount() {
this.getUserInfo(0);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should be in componentDidMount, componentWillMount is deprecated in higher version of react. and we should pass this.state.page to method getUserInfo as its initial value is 0

getUserInfo(page) {
console.log("getting user info fior page " + page);

const URL = `https://reqres.in/api/users/?page=${page}`;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be: const URL = https://reqres.in/api/users/?page=${this.state.page};

);

gotoNextPage = () => {
this.getUserInfo(this.state.page + 1);
Copy link
Contributor

@vjnathe-webonise vjnathe-webonise May 21, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be:

this.setState({
  page: this.state.page < this.state.total_pages ?   this.state.page + 1 : this.state.page,
}, this.getUserInfo);

};

gotoPreviousPage = () => {
this.getUserInfo(this.state.page - 1);
Copy link
Contributor

@vjnathe-webonise vjnathe-webonise May 21, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be:

this.setState({
  page: this.state.page > 1 ? this.state.page - 1  :  this.state.page,
}, this.getUserInfo);

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are not using Gridscreen.js. So file has been deleted

this.getUserInfo(0);
}

getUserInfo(page) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no need to pass page as parameter as we can refer it as state variable

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are not using Gridscreen.js. So file has been deleted

@@ -1,188 +1,676 @@
import React from 'react';
/*import React from "react";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clean the commented code

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes has been done as per suggestions.

</View>
);

mapStyle = [
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

move to constants or config file

}
];
componentDidMount() {
Geocoder.init("AIzaSyD7JZmztK5wE-80P8t-_IOHZQinVtx4Dio");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

token should be from config

ScreenOrientation.allowAsync(ScreenOrientation.Orientation.ALL);
if (Platform.OS === "android" && !Constants.isDevice) {
console.log("Permission denied");
this.setState({
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can not do setState on component which is not mounted yet, use componentDidMount instead

}
}

const styles = StyleSheet.create({
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

move to component style file

}
};

mapStyle = [
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

move to separate constant or config file

console.log("getLatsstLongs called "+locationName);
Geocoder.from(locationName)
.then(json => {
var location = json.results[0].geometry.location;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use try/catch for better error handling, what if json.results is undefined OR json.results having length 0

});
}

componentWillMount() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use componentDidMount, we can not do setState before component mount

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes has been done as per suggestions.

}


_getLocationAsync = async () => {
Copy link
Contributor

@vjnathe-webonise vjnathe-webonise May 21, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

repetitive code, we can create utility async function for this

export default class UserInfoDBManager extends Component {

constructor() {
this.sqlite = SQLite;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fix indentation

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

UserInfoDBManager.js file has been deleted.No used in App

location: "1"
}).then((db) => {
this.dbInstance = db;
})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

error case not handled ?


createTable() {
return new Promise((resolve, reject) => {
this.dbInstance.executeSql('CREATE TABLE IF NOT EXISTS ' + localDB.tableName.tblLogin + ' (id INTEGER PRIMARY KEY ,firstName TEXT,lastName TEXT,avator:TEXT)'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is this.dbInstance is undefined ? this is the case where DB connection failed.

this.dbInstance.executeSql(
"DELETE FROM"+ localDB.tableName.tblLogin
).then((val) => {
resolve(true);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no need to return true/false explicitly, you can tread resolve callback for positive flow and reject callback for error flow

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants