Instantly share code, notes, and snippets.

What would you like to do?
class App extends Component {
state = {
users: [{name: 'Jim', surname: 'Smith', age: 33}]
componentDidMount() {
async fetchUsers() {
const response = await fetch('');
const users = await response.json();
render() {
return (
<div className="App">
<header className="App-header">
// huge amount code for header
<th>First name</th>
<th>Last name</th>
{, index) => (
<tr key={index}>
<td><input value={} onChange={/* update name in the state */}/></td>
<td><input value={user.surname} onChange={/* update surname in the state*/}/></td>
<td><input value={user.age} onChange={/* update age in the state */}/></td>
<button onClick={() => this.saveUsersOnTheBackend()}>Save</button>
saveUsersOnTheBackend(row) {
fetch('', {
method: "POST",
body: JSON.stringify(this.state.users),
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment