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

Paginated list#2

Open
rakeshM-Webonise wants to merge 44 commits intomasterfrom
paginated-list
Open

Paginated list#2
rakeshM-Webonise wants to merge 44 commits intomasterfrom
paginated-list

Conversation

@rakeshM-Webonise
Copy link
Copy Markdown

No description provided.

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

export default (variables /*: * */ = variable) => {
const bodyTheme = {
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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.

Comment thread EXPO/screens/Constants.js Outdated
@@ -0,0 +1,25 @@
var localDB ={
Copy link
Copy Markdown
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

Comment thread EXPO/screens/DrawerScreen.js Outdated
</Text>
</View>
<View style={styles.menuItem}>
<Image source={{uri:'https://img.icons8.com/ios/60/000000/google-nearby.png'}}/>
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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)

Comment thread EXPO/screens/GridScreen.js Outdated
@@ -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
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

combine 2 imports

Comment thread EXPO/screens/GridScreen.js Outdated
};

componentWillMount() {
this.getUserInfo(0);
Copy link
Copy Markdown
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

Comment thread EXPO/screens/GridScreen.js Outdated
getUserInfo(page) {
console.log("getting user info fior page " + page);

const URL = `https://reqres.in/api/users/?page=${page}`;
Copy link
Copy Markdown
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};

Comment thread EXPO/screens/GridScreen.js Outdated
);

gotoNextPage = () => {
this.getUserInfo(this.state.page + 1);
Copy link
Copy Markdown
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);

Comment thread EXPO/screens/GridScreen.js Outdated
};

gotoPreviousPage = () => {
this.getUserInfo(this.state.page - 1);
Copy link
Copy Markdown
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
Copy Markdown
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

Comment thread EXPO/screens/GridScreen.js Outdated
this.getUserInfo(0);
}

getUserInfo(page) {
Copy link
Copy Markdown
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
Copy Markdown
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

Comment thread EXPO/screens/HomeScreen.js Outdated
@@ -1,188 +1,676 @@
import React from 'react';
/*import React from "react";
Copy link
Copy Markdown
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
Copy Markdown
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.

Comment thread EXPO/screens/HomeScreen.js Outdated
</View>
);

mapStyle = [
Copy link
Copy Markdown
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

Comment thread EXPO/screens/HomeScreen.js Outdated
}
];
componentDidMount() {
Geocoder.init("AIzaSyD7JZmztK5wE-80P8t-_IOHZQinVtx4Dio");
Copy link
Copy Markdown
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

Comment thread EXPO/screens/HomeScreen.js Outdated
ScreenOrientation.allowAsync(ScreenOrientation.Orientation.ALL);
if (Platform.OS === "android" && !Constants.isDevice) {
console.log("Permission denied");
this.setState({
Copy link
Copy Markdown
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

Comment thread EXPO/screens/HomeScreen.js Outdated
}
}

const styles = StyleSheet.create({
Copy link
Copy Markdown
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

Comment thread EXPO/screens/MapScreen.js Outdated
}
};

mapStyle = [
Copy link
Copy Markdown
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

Comment thread EXPO/screens/MapScreen.js Outdated
console.log("getLatsstLongs called "+locationName);
Geocoder.from(locationName)
.then(json => {
var location = json.results[0].geometry.location;
Copy link
Copy Markdown
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

Comment thread EXPO/screens/MapScreen.js Outdated
});
}

componentWillMount() {
Copy link
Copy Markdown
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
Copy Markdown
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.

Comment thread EXPO/screens/MapScreen.js Outdated
}


_getLocationAsync = async () => {
Copy link
Copy Markdown
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

Comment thread EXPO/screens/UserInfoDBManager.js Outdated
export default class UserInfoDBManager extends Component {

constructor() {
this.sqlite = SQLite;
Copy link
Copy Markdown
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
Copy Markdown
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

Comment thread EXPO/screens/UserInfoDBManager.js Outdated
location: "1"
}).then((db) => {
this.dbInstance = db;
})
Copy link
Copy Markdown
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 ?

Comment thread EXPO/screens/UserInfoDBManager.js Outdated

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
Copy Markdown
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.

Comment thread EXPO/screens/UserInfoDBManager.js Outdated
this.dbInstance.executeSql(
"DELETE FROM"+ localDB.tableName.tblLogin
).then((val) => {
resolve(true);
Copy link
Copy Markdown
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