Skip to content

Instantly share code, notes, and snippets.

View chadmuro's full-sized avatar

Chad Murobayashi chadmuro

View GitHub Profile
@chadmuro
chadmuro / Form.js
Last active July 31, 2021 03:13
Form with no validation
import React from 'react';
import { makeStyles } from '@material-ui/core';
import TextField from '@material-ui/core/TextField';
import Button from '@material-ui/core/Button';
import { useForm, Controller } from 'react-hook-form';
const useStyles = makeStyles(theme => ({
root: {
display: 'flex',
flexDirection: 'column',
@chadmuro
chadmuro / solution2.js
Created July 29, 2021 13:57
JS - Conditionally Add Item To Array
const sports = [
"basketball",
true && "football",
false && "baseball"
].filter(Boolean);
@chadmuro
chadmuro / solution.js
Created July 29, 2021 13:55
JS - Conditionally Add Item To Array
const sports = [
"basketball",
...(true ? ["football"] : []),
...(false ? ["baseball"] : [])
];
@chadmuro
chadmuro / app.js
Last active July 27, 2021 09:05
Intro to Express
const express = require('express');
const app = express();
// Create HTTP get route
app.get('/', (req, res) => {
res.send('Hello World!');
});
// Start the server
@chadmuro
chadmuro / Button.js
Created July 22, 2021 08:58
Material-UI Button
import { makeStyles } from '@material-ui/core/styles';
import Button from '@material-ui/core/Button';
const useStyles = makeStyles({
button: {
backgroundColor: 'yellow',
color: 'black',
'&:hover': {
backgroundColor: 'olive',
},
@chadmuro
chadmuro / Autocomplete.js
Created July 10, 2021 03:07
Material-UI Autocomplete
import React, { useState } from 'react';
import TextField from '@material-ui/core/TextField';
import Autocomplete from '@material-ui/lab/Autocomplete';
import { nbaTeams } from './nbaTeams';
const NbaAutocomplete = () => {
const [selectedTeam, setSelectedTeam] = useState(null);
console.log(selectedTeam);
@chadmuro
chadmuro / nbaTeams.js
Last active July 10, 2021 02:21
NBA Teams Array
export const nbaTeams = [
{ id: 1, name: 'Atlanta Hawks' },
{ id: 2, name: 'Boston Celtics' },
{ id: 3, name: 'Brooklyn Nets' },
{ id: 4, name: 'Charlotte Hornets' },
{ id: 5, name: 'Chicago Bulls' },
{ id: 6, name: 'Cleveland Cavaliers' },
{ id: 7, name: 'Dallas Mavericks' },
{ id: 8, name: 'Denver Nuggets' },
{ id: 9, name: 'Detroit Pistons' },
@chadmuro
chadmuro / Calendar.js
Created June 12, 2021 05:32
Full Calendar
import FullCalendar from '@fullcalendar/react';
import dayGridPlugin from '@fullcalendar/daygrid';
import timeGridPlugin from '@fullcalendar/timegrid';
import interactionPlugin from '@fullcalendar/interaction';
const events = [
{
id: 1,
title: 'event 1',
start: '2021-06-14T10:00:00',
@chadmuro
chadmuro / contact.js
Last active June 6, 2021 07:20
Next.js SendGrid
const mail = require('@sendgrid/mail');
mail.setApiKey(process.env.SENDGRID_API_KEY);
export default async (req, res) => {
const body = JSON.parse(req.body);
const message = `
Name: ${body.name}\r\n
Email: ${body.email}\r\n
@chadmuro
chadmuro / index.js
Created June 6, 2021 01:57
Next.js SendGrid
import { useState } from 'react';
import Head from 'next/head';
import styles from '../styles/Home.module.css';
export default function Home() {
const [name, setName] = useState('');
const [email, setEmail] = useState('');
const [message, setMessage] = useState('');
const handleSubmit = e => {