diff --git a/.eslintrc.json b/.eslintrc.json
index a242ad8..1ad936c 100644
--- a/.eslintrc.json
+++ b/.eslintrc.json
@@ -3,8 +3,12 @@
"ecmaVersion": 2017,
"sourceType": "module",
"ecmaFeatures": {
- "jsx": false
- }
+ "jsx": true
+ },
+ "extends": [
+ "eslint:recommended",
+ "plugin:react/recommended"
+ ]
},
"env": {
"browser": true,
@@ -27,7 +31,7 @@
"func-names": 1,
"indent": ["error", 2, { "SwitchCase": 1 }],
"lines-around-comment": ["error", { "beforeBlockComment": true, "allowArrayStart": true }],
- "max-len": [1, 180, 2], // 2 spaces per tab, max 80 chars per line
+ "max-len": [1, 180, 2],
"new-cap": 1,
"newline-before-return": "error",
"no-array-constructor": 1,
@@ -49,7 +53,8 @@
"space-infix-ops": 1,
"vars-on-top": 1,
"no-multiple-empty-lines": ["error", { "max": 1, "maxEOF": 1 }],
- "spaced-comment": ["error", "always", { "markers": ["/"] }]
+ "spaced-comment": ["error", "always", { "markers": ["/"] }],
+ "multiline-comment-style": ["error", "starred-block"]
}
}
diff --git a/.idea/jsLinters/eslint.xml b/.idea/jsLinters/eslint.xml
index 118d674..b269b71 100644
--- a/.idea/jsLinters/eslint.xml
+++ b/.idea/jsLinters/eslint.xml
@@ -1,6 +1,6 @@
-
+
\ No newline at end of file
diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index 07f36cc..feb7739 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -2,9 +2,12 @@
-
+
+
+
+
@@ -39,15 +42,17 @@
+
+
-
+
@@ -56,7 +61,7 @@
-
+
@@ -101,7 +106,7 @@
1569429914875
-
+
1569512995385
@@ -131,7 +136,14 @@
1569576014565
-
+
+ 1569577010198
+
+
+
+ 1569577010198
+
+
@@ -154,6 +166,7 @@
-
+
+
\ No newline at end of file
diff --git a/package.json b/package.json
index d0bac70..0350c87 100644
--- a/package.json
+++ b/package.json
@@ -4,6 +4,7 @@
"private": true,
"dependencies": {
"axios": "^0.19.0",
+ "eslint": "^6.4.0",
"react": "^16.9.0",
"react-dom": "^16.9.0",
"react-scripts": "3.1.2"
@@ -28,5 +29,8 @@
"last 1 firefox version",
"last 1 safari version"
]
+ },
+ "devDependencies": {
+ "eslint-plugin-react": "^7.14.3"
}
}
diff --git a/src/App.js b/src/App.js
index 474b9c1..d3bf8cf 100644
--- a/src/App.js
+++ b/src/App.js
@@ -1,4 +1,5 @@
import React, { Component } from 'react';
+import PropTypes from 'prop-types';
import Navbar from './components/layout/Navbar';
import Users from './components/users/Users';
import Search from './components/users/Search';
@@ -11,12 +12,24 @@ class App extends Component {
'loading': false
};
- async componentDidMount() {
+ static propTypes = {
+ searchUsers:PropTypes.func.isRequired
+ };
+
+ /*async componentDidMount() {
this.setState({ 'loading': true });
const res = await axios.get(`https://api.github.com/users?client_id=${process.env.REACT_APP_GITHUB_CLIENT_ID}&client_secret=${process.env.REACT_APP_GITHUB_CLIENT_SECRET}`);
console.log(res.data);
this.setState({ 'users':res.data, 'loading': false });
- }
+ }*/
+ // Search github users
+ searchUsers = async (text) => {
+
+ this.setState({ 'loading': true });
+ const res = await axios.get(`https://api.github.com/search/users?q=${text}&client_id=${process.env.REACT_APP_GITHUB_CLIENT_ID}&client_secret=${process.env.REACT_APP_GITHUB_CLIENT_SECRET}`);
+ console.log(res.data);
+ this.setState({ 'users':res.data.items, 'loading': false });
+ };
render() {
return (
@@ -24,7 +37,7 @@ class App extends Component {
-
+
diff --git a/src/components/users/Search.js b/src/components/users/Search.js
index 4e6f1a9..4dfdd70 100644
--- a/src/components/users/Search.js
+++ b/src/components/users/Search.js
@@ -13,7 +13,8 @@ class Search extends Component {
onSubmit = e => {
e.preventDefault();
- console.log(this.state.text);
+ this.props.searchUsers(this.state.text);
+ this.setState({text:''});
};
render() {