Skip to content

Instantly share code, notes, and snippets.

View singhArmani's full-sized avatar
🎯
Focusing

Amandeep Singh singhArmani

🎯
Focusing
View GitHub Profile
@singhArmani
singhArmani / dabblet.css
Last active July 30, 2019 11:50
Untitled
.first {
padding: 10px;
height: 300px;
margin: 10px 30px 30px 10px;
background: red;
box-shadow: 0 0 0 10px gold;
width: 100px;
text-align: center;
float: left
}
@singhArmani
singhArmani / dabblet.css
Last active July 22, 2019 02:37
Untitled
.first {
padding: 10px;
height: 300px;
margin: 10px 30px 30px 10px;
background: red;
box-shadow: 0 0 0 10px gold;
width: 100px;
text-align: center;
float: left
}
@singhArmani
singhArmani / dabblet.css
Created July 20, 2019 13:46
Block level and Height
/**
* Block level and Height
*/
div {
width: 600px;
background-color: gold;
}
/*Hard to read if used opacity*/
div {
box-shadow: 0 0 0 5px gold;
background: #f06;
font-size: 24px;
position: relative;
width:600px;
}
.opac {
@singhArmani
singhArmani / hoisting.csv
Last active July 16, 2019 23:55
Hoisting Table
Keyword Hoisting Scope Creates global properties
var Declaration Function Yes
let Temporal dead zone Block No
const Temporal dead zone Block No
function Complete Block Yes
class No Block No
import Complete Module-global No
componentDidMount() {
setTimeout(() => {
// checking if component hasn't been unmounted and
// thus it's safe to call setState
if(!this.isUnMounted) {
this.setState({
value: 20
});
}
}, 1000);
// Inside parent component
state = {
isLoading: true,
posts: [],
isErrorLoading: false,
error: null
};
// rendering logic handles by Parent Component (if statements)
// but the actual rendering job is handled by nested components
import React from "react";
export default class Counter extends React.PureComponent {
state = {
count: 0 // initial state
};
handleIncrement = () => {
// as increment count depends on previous count value,
// we should use updater function
this.setState(prevState => ({
const someArbitraryObj = {
name: "object has no name",
someArray: [
{
id: 1,
color: "red",
value: {
nestedValue: 20
}
},
var array = [];
for(var i = 0; i <3; i++) {
array.push(() => i);
}
var newArray = array.map(el => el());
console.log(newArray); // ??