- Method ordering
- PropTypes + DefaultProps
- Destructuring from props and state (intent)
- Avoid instance methods (only for things that matters to React)
- Components > render methods (renderElements/renderItems/etc)
- Pure render function (no
window
orMath.random()
) - Containers (connected) vs. Presentational Components (pure)
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { History, Location } from "history"; | |
import { MatchResult } from "path-to-regexp"; | |
import { ReactElement, useContext, useEffect, useState } from "react"; | |
import React from "react"; | |
import { getPathMatch } from "./utils/routing"; | |
export interface RouterContextInterface { | |
history?: History; | |
location?: Location; | |
basePath: string; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** @jsx React.DOM */ | |
'use strict'; | |
var React = require('react'); | |
var MasonryMixin = require('./react-masonry-mixin.js'); | |
var masonryOptions = { | |
transitionDuration: 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Import dependencies | |
*/ | |
const { EventEmitter } = require('events'); | |
const ReconnectingWebSocket = require('reconnecting-websocket'); | |
/** | |
* Export a function that creates a websocket connection interface | |
*/ | |
export default function createReconnectingWebsocket(uri) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* WHY? - BECAUSE EXCEPTIONS/TRY/CATCH IS A GLOBAL HORRIBLE MESS :-( | |
* Check out error handling in golang: https://blog.golang.org/error-handling-and-go | |
*/ | |
/** | |
* Wrap an "unsafe" promise | |
*/ | |
function safePromise(promise) { | |
return promise |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.App { | |
text-align: center; | |
} | |
.App-logo { | |
animation: App-logo-spin infinite 20s linear; | |
height: 10vmin; | |
} | |
.App-header { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Instance method anti pattern | |
*/ | |
class MyComponent extends React.Component { | |
computeThatThing() { | |
return this.props.a + this.props.b; | |
} | |
render() { | |
return ( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { log } = console; | |
const Undefined = new Proxy(function() {}, { | |
get(target, key, receiver) { | |
if (key === 'name') { | |
return 'Undefined'; | |
} | |
return Undefined; | |
}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Dependencies | |
*/ | |
const spawn = require('cross-spawn'); | |
/** | |
* Package.json | |
*/ | |
const packageJson = require('../package.json'); |
NewerOlder