Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"name": "new",
"name": "test-react-app",
"version": "1.0.0",
"description": "",
"keywords": [],
"main": "src/index.js",
"dependencies": {
"react": "16.5.2",
"react-dom": "16.5.2",
"react": "16.7.0-alpha.0 - next",
"react-dom": "16.7.0-alpha.0 - next",
"react-scripts": "2.0.3"
},
"devDependencies": {},
Expand Down
39 changes: 32 additions & 7 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,42 @@
import React from "react";
import React, { useState, useEffect } from "react";
import ReactDOM from "react-dom";

import "./styles.css";

function App() {
const [count, setCount] = useState(42);
const [users, setUsers] = useState([]);
useEffect(() => {
fetch("https://api.github.com/users")
.then(response => response.json())
.then(data => {
setUsers(data); //save users in the store
});
}, []);

return (
<div className="App">
<h1>Hello CodeSandbox</h1>
<h2>Start editing to see some magic happen!</h2>
<h1> This is super cool</h1>
<h3> I look forward to using this more ... </h3>
<h2> </h2>
<h3> This is the key of the kingdom</h3>
<div>
<h3>Counter</h3>
<h1>{count} </h1>
<button onClick={() => setCount(count + 1)}> Count up </button>
</div>
<div>
<h3> Git Users </h3>
<div className="section">
{users.map(user => (
<div key={user.id} className="card">
<h5>
{" "}
<a href={user.html_url} target="_blank">
<img src={user.avatar_url} width="40px" height="40px" />{" "}
</a>
{user.login}{" "}
</h5>
</div>
))}
</div>
</div>
</div>
);
}
Expand Down