Skip to content

Instantly share code, notes, and snippets.

View michaelmcshinsky's full-sized avatar

Michael McShinsky michaelmcshinsky

View GitHub Profile
@michaelmcshinsky
michaelmcshinsky / 0_reuse_code.js
Created July 10, 2014 14:01
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@michaelmcshinsky
michaelmcshinsky / handleChangeNew
Last active November 4, 2017 03:44
Useful snippets for handle change events that handle multiple situations fast and effectively
// V.1
// Use Case: Input, Checkbox & Select Handling
handleChange = (e) => {
this.setState({[e.target.name]: e.target.type === 'checkbox' ? e.target.checked : e.target.value;
}
// V.2
// Use Case: State Object Handling for: Input, Checkbox & Select
handleChange = (e) => {
// your target object
import React, { Component } from 'react'
import Header from './Header'
import Sidebar from './Sidebar'
export default class App extends Component {
constructor(props) {
super(props)
this.state = {
isSidebarOpen: false
}
header.Header.Header--top {
width: 100vw;
position: relative;
left: 50%;
right: 50%;
margin-left: -50vw;
margin-right: -50vw;
margin-top: -50px;
}
@michaelmcshinsky
michaelmcshinsky / finding-objects-and-values-in-arrays-part-1-1.js
Last active October 22, 2019 03:04
finding-objects-and-values-in-arrays-part-1
let namesArray = ['Adam', 'Bell', 'Cody', 'Dawn'];
let textArray = ['Dog', 'Cat', 'Horse', 'Cow'];
let numbersArray = [1, 2, 3, 4];
@michaelmcshinsky
michaelmcshinsky / finding-objects-and-values-in-arrays-part-2-1.js
Last active October 22, 2019 03:05
finding-objects-and-values-in-arrays-part-2
let arr = [
{id: 1, name: 'Adam'},
{id: 2, name: 'Bell'},
{id: 3, name: 'Cody'},
{id: 4, name: 'Dawn'}
];
@michaelmcshinsky
michaelmcshinsky / optimizing-state-change-in-react-1.jsx
Last active October 18, 2019 12:41
optimizing-state-change-in-react
import React from 'react';
export class SignUpForm extends React.Component {
constructor(props) {
super(props);
this.state = {
name: '',
email: ''
};
}
import React, { useState } from 'React';
export function Form() {
const [name, setName] = useState('');
const [email, setEmail] = useState('');
const handleSubmit = event => {
event.preventDefault();
}
@michaelmcshinsky
michaelmcshinsky / ata.json
Last active November 5, 2019 13:18
vscode-sync-settings
{
"api": {
"CredentialUserData": {
"__compat": {
"mdn_url": "https://developer.mozilla.org/docs/Web/API/CredentialUserData",
"support": {
"chrome": {
"version_added": "60"
},
"chrome_android": {
@michaelmcshinsky
michaelmcshinsky / states-array.json
Last active December 12, 2019 21:05 — forked from mshafrir/states_hash.json
US states in JSON form
[
{
"name": "Alabama",
"abbreviation": "AL"
},
{
"name": "Alaska",
"abbreviation": "AK"
},
{