Skip to content

Instantly share code, notes, and snippets.

James K Nelson jamesknelson

Block or report user

Report or block jamesknelson

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View HighlightedCodeBlock.js
import React, { PureComponent, PropTypes } from "react"
import Prism from 'prismjs'
const codeBlockAliases = {
'js': 'jsx',
'html': 'markup',
'mdx': 'markdown',
'md': 'markdown',
}
@jamesknelson
jamesknelson / Pitch.mdx
Last active Feb 3, 2017
mdx: A markdown-like format that gives you inline JSX, and compiles to a React stateless function
View Pitch.mdx
metaDescription
junctions.js lets you add routes to your React components.

import Link from './Link' import ButtonTheme from './ButtonTheme' import ExampleSet from './ExampleSet' import ComponentExample from './ComponentExample' import GistVanillaExample from './examples/the-gist-vanilla' import GistSugarFreeExample from './examples/the-gist-sugar-free' import BasicExample from './examples/basic'

@jamesknelson
jamesknelson / gist:d18cbc97aeca53675b4e
Created Oct 5, 2015
Raw React `navigated` action
View gist:d18cbc97aeca53675b4e
function navigated() {
// Choose which component to render based on browser URL
var component = window.location.hash == "#/"
? React.createElement('div', {}, "Index Page")
: React.createElement('div', {}, "Not Found")
// Render the new component to the page's #react-app element
ReactDOM.render(
component,
document.getElementById('react-app')
@jamesknelson
jamesknelson / BlackTriangle.js
Last active Apr 8, 2019
A black triangle. It spins if ES6 works, otherwise it doesn't.
View BlackTriangle.js
export default class BlackTriangle {
constructor(selector) {
this.angle = 0;
this.innerEl = document.querySelector(selector).querySelector('.BlackTriangle-inner');
}
rotate(amount) {
this.angle = (this.angle + amount) % 360;
}
@jamesknelson
jamesknelson / react-parent-context-patch.js
Last active Jan 9, 2016
Use parent context instead of owner context in facebook/react (#2112)
View react-parent-context-patch.js
var ReactInstanceMap = require("react/lib/ReactInstanceMap");
var ReactLifeCycle = require("react/lib/ReactLifeCycle");
var ReactNativeComponent = require("react/lib/ReactNativeComponent");
var ReactReconciler = require("react/lib/ReactReconciler");
var emptyObject = require("react/lib/emptyObject");
var invariant = require("react/lib/invariant");
var warning = require("react/lib/warning");
var ReactCompositeComponentMixin = require('react/lib/ReactCompositeComponent').Mixin;
View Link.coffee
You can’t perform that action at this time.