Skip to content

Instantly share code, notes, and snippets.

import React, { Component } from 'react';
export default class Item extends Component{
constructor(props){
super(props);
this.state = {
num: props.num,
isSaved: false
}
import React, { Component } from 'react';
import Item from './Item';
import './App.css';
class App extends Component {
constructor(){
super();
this.state = {
@joskid
joskid / storageHooks.js
Created May 31, 2020 10:12 — forked from Paratron/storageHooks.js
Enables you to use hooks for localStorage and sessionStorage that even redraw all components when their respective values change.
import React from "react";
let lsBus = {};
let ssBus = {};
/**
* Redraw all components that have a hook to localStorage with the given key.
* @param {string} key
* @param {*} newValue
*/
//Sending Data to the Server using Fetch()
//using jsonplaceholder for the data
//GET - queryStrings
// http://jsonplaceholder.typicode.com/posts?userId=1&postId=65
// http://jsonplaceholder.typicode.com/todos?userId=2
//POST
// http://jsonplaceholder.typicode.com/posts
const root = 'http://jsonplaceholder.typicode.com/';
let uri = root + 'posts';
const people = [
{ id: 12, name: 'Billy', dob: '1998-10-05' },
{ id: 123, name: 'Bart', dob: '1993-02-15' },
{ id: 45, name: 'Belinda', dob: '1996-01-31' },
{ id: 67, name: 'Bonnie', dob: '1998-04-09' },
{ id: 89, name: 'Brenda', dob: '1996-07-08' },
{ id: 34, name: 'Bobby', dob: '1994-09-12' },
{ id: 234, name: 'Blake', dob: '2000-01-01' },
];
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Scroll To Text Fragment</title>
<style>
* {
box-sizing: border-box;
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>CSS Classes vs Ids</title>
<style>
* {
box-sizing: border-box;
padding: 0;
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
<style>
:root{
--font: 1rem;
--line: calc(var(--font) * 2);
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
<style>
html {
font-size: 20px;
font-weight: 300;
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>FormData Objects</title>
</head>