Skip to content

Instantly share code, notes, and snippets.

View mjackson's full-sized avatar
💿

Michael Jackson mjackson

💿
View GitHub Profile
import React from "react";
import pathToRegexp from "path-to-regexp";
function Home() {
return <h1>Home</h1>;
}
function About() {
return <h1>About</h1>;
}

Keybase proof

I hereby claim:

  • I am mjackson on github.
  • I am mjackson (https://keybase.io/mjackson) on keybase.
  • I have a public key ASDn-_bfhdzaHqvj4gcakU4yKWlK5RyzlcXQRJMQqYp2fwo

To claim this, I am signing this object:

@mjackson
mjackson / MyComponent.js
Last active March 7, 2018 05:38
Can we just plop some CSS right smack in the middle of our JavaScript code?!
import React from "react";
body {
font-family: Helvetica, sans-serif;
}
.header-text {
font-weight: bold;
font-size: 2em;
}
@mjackson
mjackson / multiple-git-hooks.sh
Created February 6, 2018 00:58
Run multiple scripts for the same git hook
#!/bin/sh
# This script should be saved in a git repo as a hook file, e.g. .git/hooks/pre-receive.
# It looks for scripts in the .git/hooks/pre-receive.d directory and executes them in order,
# passing along stdin. If any script exits with a non-zero status, this script exits.
script_dir=$(dirname $0)
hook_name=$(basename $0)
hook_dir="$script_dir/$hook_name.d"
{
"_id": "@dollarshaveclub-engineering/ui",
"_rev": "2-5773c0c926d450044de3c87bc8233fad",
"name": "@dollarshaveclub-engineering/ui",
"description": "DSC Web UI",
"dist-tags": {
"latest": "2.6.4"
},
"versions": {
"2.6.3": {
@mjackson
mjackson / broadcast_subscriber_deprecations.md
Last active April 11, 2018 08:44
More information about <Broadcast>/<Subscriber> deprecations in react-broadcast

<Broadcast> and <Subscriber> are being deprecated

<Broadcast> and <Subscriber> are being deprecated in react-broadcast in favor of a new API inspired by the new React context RFC. The goals of this change for react-broadcast users are:

  • Make it easier to upgrade to the new React context API when it eventually lands
  • Remove ambiguity around channels

How to upgrade to the new API

Instead of using pre-built and components, you create them for yourself. So instead of:

/*eslint-disable no-alert */
////////////////////////////////////////////////////////////////////////////////
// Exercise:
//
// Using context, implement the <Form>, <SubmitButton>, and <TextInput>
// components such that:
//
// - Clicking the <SubmitButton> calls <Form onSubmit>
// - Hitting "Enter" while in a <TextInput> submits the form
// - Don't use a <form> element, we're intentionally recreating the
@mjackson
mjackson / Dockerfile
Created October 13, 2017 00:30
Running `gatsby develop` on a container in development
FROM node:8
WORKDIR /home/node/app
ADD https://github.com/Yelp/dumb-init/releases/download/v1.1.1/dumb-init_1.1.1_amd64 /usr/local/bin/dumb-init
RUN chmod +x /usr/local/bin/dumb-init
COPY package.json yarn.lock ./
RUN yarn --pure-lockfile
COPY . .
import React from 'react'
function Navigation({ render }) {
// Call render() first to get the children. You can pass
// whatever state you need here so they know how to render.
let children = render()
children = React.Children.map(children, child => (
React.cloneElement(child, {
// put whatever additional props you need here!
import React from 'react'
import ReactDOM from 'react-dom'
import PropTypes from 'prop-types'
function ContentToggle(props) {
let summaryClassName = 'ContentToggle__Summary'
if (props.isOpen)
summaryClassName += ' ContentToggle__Summary--is-open'