Skip to content

Instantly share code, notes, and snippets.

View jsjoeio's full-sized avatar

Joe Previte jsjoeio

View GitHub Profile
@jsjoeio
jsjoeio / prompt.js
Created May 9, 2020 22:16
Gatsby Recipe: Generate a Blog Post Faster with Hygen - prompt.js
const dayjs = require('dayjs')
const open = require('open')
module.exports = {
prompt: ({ prompter }) => {
return new Promise((resolve, reject) => {
prompter
.prompt([
{
type: 'input',
@jsjoeio
jsjoeio / feature_request.md
Created March 1, 2020 21:01
Create a GitHub Issue Template - example issue template
name about labels
Feature Request 💡
Suggest a new idea for the project.
enhancement

Summary

Brief explanation of the feature.

@jsjoeio
jsjoeio / tsconfig.json
Created February 23, 2020 20:22
Migrating React to TypeScript - tsconfig.json
{
"exclude": ["node_modules", "build", "public"],
"compilerOptions": {
/* Basic Options */
// "incremental": true, /* Enable incremental compilation */
"target": "es5" /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */,
"module": "esnext" /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */,
// "lib": [], /* Specify library files to be included in the compilation. */
"allowJs": true /* Allow javascript files to be compiled. */,
// "checkJs": true, /* Report errors in .js files. */
@jsjoeio
jsjoeio / pull_request_template.md
Created February 17, 2020 03:50
Create a GitHub PR Template - example PR template

This PR...

Changes

Screenshots

(prefer animated gif)

Checklist

  • tested locally
  • added new dependencies
  • updated the docs
  • added a test
@jsjoeio
jsjoeio / hw-response.md
Created January 11, 2020 15:21
The JavaScript Universe - Homework Response

Answers

  1. Open some JavaScript code that you have been working on and put console.log(typeof(something)) in it, replacing something with different variables in your code. Can you find an example for every value type in the list above? Try to “collect” as many types as you can.
  • Undefined (undefined) (I know this isn't the same as undefined itself but it was the closest I could find)
 if (typeof window !== 'undefined') {
      return localStorage.getItem('theme') || 'default'
    } else {
      return 'default'
@jsjoeio
jsjoeio / Header.tsx
Created January 8, 2020 00:58
first revision
import React from 'react'
type Props = {
text: string;
color: string;
}
export const Header: React.FC<Props> = ({text, color}) => {
return <h1 style={{ color }}>{text}</h1>
}
@jsjoeio
jsjoeio / Header.jsx
Created January 8, 2020 00:57
The header
import React from 'react'
export const Header = ({text, color}) => {
return <h1 style={{ color }}>{text}</h1>
}
Header.defaultProps = {
color: 'red',
text: 'Hello world!'
}
@jsjoeio
jsjoeio / Header.tsx
Last active December 31, 2019 19:28
React component
import React from 'react'
type Props = {
text: string;
color: string;
}
export const Header: React.FC<Props> = ({text = 'Hello world!', color = 'red'}) => {
return <h1 style={{ color }}>{text}</h1>
}
@jsjoeio
jsjoeio / example.tsx
Created December 12, 2019 14:07
React TypeScript Component: Function Declaration vs. Function Expression
import React from 'react'
// Written as a function declaration
function Heading(): React.Node {
return <h1>My Website Heading</h1>
}
// Written as a function expression
const OtherHeading: React.FC = () => <h1>My Website Heading</h1>
@jsjoeio
jsjoeio / Header.tsx
Last active December 10, 2019 03:26
React TypeScript: function delclaration vs. function expression
import React from 'react'
// Written as a function declaration
function Heading(): React.Node {
return <h1>My Website Heading</h1>
}
// Written as a function expression
const OtherHeading: React.FC = () => <h1>My Website Heading</h1>