Skip to content

Instantly share code, notes, and snippets.

@joquendo
joquendo / react-createRef.js
Created May 12, 2020 05:12
React createRef
class Form extends React.Component {
userNameInput = React.createRef();
handleSubmit = (event) => {
event.preventDefault();
console.log(this.userNameInput.current
}
render() {
return (
<form onSubmit={this.handleSubmit}>
<input
@joquendo
joquendo / promisesAsyncAwait.js
Created May 12, 2020 05:10
Promises Async/Await
//const fetchData () => {
// fetch('https://api.github.com').then(resp => {
// resp.json().then(data => {
// console.log(data);
// });
// });
//}
const fetchData = async () => {
const resp = await fetch('https://api.github.com');
@joquendo
joquendo / classes.js
Last active May 12, 2020 05:11
Javascript classes model
class Person {
constructor (name) {
this.name = name;
}
greet() {
console.log(`Hello, ${this.name}!`);
}
}