Skip to content

Instantly share code, notes, and snippets.

View thomasblaymire's full-sized avatar
💻
Coding

Tom Blaymire thomasblaymire

💻
Coding
View GitHub Profile
// REF: https://medium.com/with-orus/the-5-commandments-of-clean-error-handling-in-typescript-93a9cbdf1af5
// baseError
type Jsonable = string | number | boolean | null | undefined | readonly Jsonable[] | { readonly [key: string]: Jsonable } | { toJSON(): Jsonable }
export class BaseError extends Error {
public readonly context?: Jsonable
constructor(message: string, options: { error?: Error, context?: Jsonable } = {}) {
const { cause, context } = options
@thomasblaymire
thomasblaymire / GraphQL Example 1.js
Created April 24, 2019 02:02
GraphQL Example 1
import { GraphQLServer } from 'graphql-yoga';
// Scalar types - String, Boolean, Int, Float, ID,
// Type Definitions (schema)
const typeDefs = `
type Query {
greeting(name: String, job: String): String!
me: User!
post: Post!
import React, { Component } from 'react';
import Navigation from './Navigation';
import styled, { ThemeProvider, createGlobalStyle } from 'styled-components';
const theme = {
red: '#FF0000',
black: '#393939',
maxWidth: '1300px',
bs: '0 12px 24px 0 rgba(0, 0, 0, 0.09)',
};
@thomasblaymire
thomasblaymire / imported-styled-example.js
Created February 13, 2019 22:01
imported-styled-cart.js
import React from 'react';
import styled from 'styled-components'
import CartStyles from './styles/CartStyles';
const Cart = () => (
<CartStyles>
<div className="intro">
<p>You Have 3 items in your cart.</p>
</div>
<ul>
import React from 'react';
import styled from 'styled-components';
const HeroWrapper = styled.div`
width: 100%;
min-hieght: 40vh;
background: ${props => props.theme.red}; // Using a theme property.
.standard-div {
text-transform: uppercase;
@thomasblaymire
thomasblaymire / hooksOneState.js
Last active December 30, 2018 10:13
React Hooks Single State
import React, { useState } from 'react';
const todo = props => {
const [userState, setUserState] = useState({
userName: '',
userList: [],
});
const inputChangeHandler = event => {
setUserState({