-
Base primitives:
- state
- computed
- effect
-
Higher level primitives:
- async / resource (non-cached)
-
query / mutation (cached)
Loading
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
.App { | |
text-align: center; | |
} | |
.App-logo { | |
animation: App-logo-spin infinite 20s linear; | |
height: 10vmin; | |
} | |
.App-header { |
- 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)
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
/** | |
* Dependencies | |
*/ | |
const spawn = require('cross-spawn'); | |
/** | |
* Package.json | |
*/ | |
const packageJson = require('../package.json'); |
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 express = require('express'); | |
const history = require('connect-history-api-fallback'); | |
/** | |
* Environment / configuration | |
*/ | |
const port = process.env.PORT || 3000; |
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
1. Basic Syntax | |
- http://jsbin.com/kixovom/ | |
2. Types and Literals | |
- http://jsbin.com/bagofoc/ | |
3. Truth and Equality | |
- http://jsbin.com/feyepub/ | |
4. Functions | |
- http://jsbin.com/tuzezip/ | |
5. Objects | |
- http://jsbin.com/qukaqig/ |
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 { HTTPFetchNetworkInterface, printAST } from 'apollo-client'; | |
/** | |
* Serialize a object to a query string | |
* @source https://stackoverflow.com/questions/1714786/query-string-encoding-of-a-javascript-object#comment47677757_18116302 | |
*/ | |
function serialize( obj ) { | |
return `?` + Object.keys(obj).map(k => k + `=` + encodeURIComponent(obj[k])).join(`&`); | |
} |
NewerOlder