Skip to content

Instantly share code, notes, and snippets.

View paschalidi's full-sized avatar
🌐
in Mexico city

Christos Paschalidis paschalidi

🌐
in Mexico city
View GitHub Profile
function foo() {
// All variables are accessible within functions.
var bar = 'bar';
let baz = 'baz';
const qux = 'qux';
console.log(bar);
console.log(baz);
console.log(qux);
}
@paschalidi
paschalidi / React.createElement
Created December 17, 2019 10:15
What is equivalent of the following using React.createElement?
const element = (
<h1 className="greeting">
Hello, world!
</h1>
);
// answer
const element = React.createElement(
'h1',
{className: 'greeting'},
@paschalidi
paschalidi / answer
Last active December 17, 2019 10:17
Given the code defined above, can you identify two problems?
Answer:
The constructor does not pass its props to the super class. It should include the following line:
constructor(props) {
super(props);
// ...
}
The event listener (when assigned via addEventListener()) is not properly scoped because ES2015 doesn’t provide autobinding. Therefore the developer can re-assign clickHandler in the constructor to include the correct binding to this:
constructor(props) {
super(props);
class SubmitButton extends React.Component {
constructor(props) {
super(props);
this.state = {
isFormSubmitted: false
};
this.handleSubmit = this.handleSubmit.bind(this);
}
handleSubmit() {
@paschalidi
paschalidi / HOC example
Last active February 6, 2021 03:36
a simple HOC component
import React from 'react';
const withStorage = (WrappedComponent) => {
class HOC extends React.Component {
state = {
localStorageAvailable: false,
};
componentDidMount() {
this.checkLocalStorageExists();
name: CI/CD
on: [push, pull_request]
jobs:
run-tests:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [10.x]
2020/12/04 14:17:58 [INFO] Terraform version: 0.13.5
2020/12/04 14:17:58 [INFO] Go runtime version: go1.14.7
2020/12/04 14:17:58 [INFO] CLI args: []string{"/usr/local/bin/terraform", "apply", "--auto-approve"}
2020/12/04 14:17:58 [DEBUG] Attempting to open CLI config file: /Users/paschalidi/.terraformrc
2020/12/04 14:17:58 [DEBUG] File doesn't exist, but doesn't need to. Ignoring.
2020/12/04 14:17:58 [DEBUG] ignoring non-existing provider search directory terraform.d/plugins
2020/12/04 14:17:58 [DEBUG] ignoring non-existing provider search directory /Users/paschalidi/.terraform.d/plugins
2020/12/04 14:17:58 [DEBUG] ignoring non-existing provider search directory /Users/paschalidi/Library/Application Support/io.terraform/plugins
2020/12/04 14:17:58 [DEBUG] ignoring non-existing provider search directory /Library/Application Support/io.terraform/plugins
2020/12/04 14:17:58 [INFO] CLI command args: []string{"apply", "--auto-approve"}