Skip to content

Commit

Permalink
Data is in state
Browse files Browse the repository at this point in the history
  • Loading branch information
AswinAsok committed Apr 15, 2021
1 parent 8479b06 commit 63e8b7e
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 10 deletions.
8 changes: 8 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"@testing-library/jest-dom": "^5.11.10",
"@testing-library/react": "^11.2.6",
"@testing-library/user-event": "^12.8.3",
"axios": "^0.21.1",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-scripts": "4.0.3",
Expand Down
27 changes: 17 additions & 10 deletions src/Components/Display/Display.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import Card from "@material-ui/core/Card";
import CardContent from "@material-ui/core/CardContent";
import Typography from "@material-ui/core/Typography";
import Button from "@material-ui/core/Button";
import Avatar from '@material-ui/core/Avatar';


const useStyles = makeStyles({
root: {
Expand All @@ -24,27 +26,31 @@ const useStyles = makeStyles({
},
});

const handleClick = (input) => {
const username = input.input

fetch(`https://api.github.com/users/${username}`)
.then(res => res.json())
.then(data => console.log(data))
}

const Display = ({ input }) => {
const classes = useStyles();
const [userdata, setUserdata] = useState({});
const [checkdata, setCheckdata] =useState(false)

const handleClick = (input) => {
const username = input.input;

fetch(`https://api.github.com/users/${username}`)
.then((res) => res.json())
.then((data) => {
setUserdata(data);
setCheckdata(true)
});
};

return (
<div className="display-container">

<div className="searchbtn">
<Button
size="large"
className="btn-search"
variant="outlined"
color="primary"
onClick={() => handleClick({input})}
onClick={() => handleClick({ input })}
>
Search
</Button>
Expand All @@ -57,6 +63,7 @@ const Display = ({ input }) => {
</Typography>
</CardContent>
</Card>

</div>
);
};
Expand Down

0 comments on commit 63e8b7e

Please sign in to comment.