Skip to content

Instantly share code, notes, and snippets.

View kentcdodds's full-sized avatar
🤓
working hard to make the world better with software

Kent C. Dodds kentcdodds

🤓
working hard to make the world better with software
View GitHub Profile
@leejsinclair
leejsinclair / protractor.conf.js
Last active August 19, 2018 06:25
Running protractor tests on codeship #testing #browser #selenium
exports.config = {
// The address of a running selenium server.
seleniumAddress: 'http://localhost:4444/wd/hub',
// Capabilities to be passed to the webdriver instance.
capabilities: {
// 'browserName': 'internet explorer', - special installation needed
// 'version':'10',
'browserName': 'chrome',
//'browserName': 'firefox'

Folder Structure

Please note

While this gist has been shared and followed for years, I regret not giving more background. It was originally a gist for the engineering org I was in, not a "general suggestion" for any React app.

Typically I avoid folders altogether. Heck, I even avoid new files. If I can build an app with one 2000 line file I will. New files and folders are a pain.

Turning Off Github Issues

My friend Michael Jackson turned off github issues on one of his smaller projects. It got me thinking...

Maintainers getting burned out is a problem. Not just for the users of a project but the mental health of the maintainer. It's a big deal for both parties. Consumers want great tools, maintainers want to create them, but maintainers don't want to be L1 tech support, that's why they

@kentcdodds
kentcdodds / README.md
Last active March 11, 2021 01:41
JavaScript Program Slicing with SliceJS
// In v2/3 you did this:
import ReactDOM from 'react-dom'
import { Router, browserHistory, Route } from 'react-router'
ReactDOM.render(
<Router>
<Route path="/about" component={About}/>
<Route path="/:username" component={User}/>
</Router>
)
@getify
getify / 1.js
Last active October 15, 2017 01:35
generators as object iterator
// ugly way
var obj = {
a: 1,
b: 2,
c: 3,
[Symbol.iterator]() {
var keys = Object.keys(this);
var idx = 0;
return {
@kentcdodds
kentcdodds / README.md
Created October 25, 2017 22:01
Rendering a function with React

Rendering a function with React

No, this isn't about render props

I'm going to clean this up and publish it in my newsletter next week!

Context

So react-i18n (not the npm one... one we made at PayPal internally) has this

@kentcdodds
kentcdodds / index.html
Last active June 24, 2021 19:48
The one true react boilerplate
<body>
<div id="⚛️"></div>
<script src="https://unpkg.com/react@16.0.0/umd/react.development.js"></script>
<script src="https://unpkg.com/react-dom@16.0.0/umd/react-dom.development.js"></script>
<script src="https://unpkg.com/babel-standalone@6.26.0/babel.js"></script>
<script type="text/babel">
ReactDOM.render(<div>Hello World!</div>, document.getElementById('⚛️'))
</script>
</body>
@kentcdodds
kentcdodds / with-foo.js
Created November 15, 2017 16:18
Which of these is a higher order component?
// Which of these things is the "Higher Order Component?"
function withFoo(Component) { // <-- this is a function, not a component
class Wrapper extends React.Component { // <-- this is a component
static displayName = `withFoo(${Component.displayName || Component.name})`
static propTypes = {innerRef: PropTypes.func}
static WrappedComponent = Component
render() {
const {innerRef, ...remainingProps} = this.props
return <Component {...remainingProps} foo="FOO!" ref={innerRef} />
@ceejbot
ceejbot / esm_in_node_proposal.md
Last active July 17, 2023 02:45
npm's proposal for supporting ES modules in node

ESM modules in node: npm edition

The proposal you’re about to read is not just a proposal. We have a working implementation of almost everything we discussed here. We encourage you to checkout and build our branch: our fork, with the relevant branch selected. Building and using the implementation will give you a better understanding of what using it as a developer is like.

Our implementation ended up differing from the proposal on some minor points. As our last action item before making a PR, we’re writing documentation on what we did. While I loathe pointing to tests in lieu of documentation, they will be helpful until we complete writing docs: the unit tests.

This repo also contains a bundled version of npm that has a new command, asset. You can read the documentation for and goals of that comma