This file contains hidden or 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 withGet = Component => | |
| class AugmentedWithGet extends React.Component { | |
| get = url => { | |
| this.setState({ | |
| isLoading: true, | |
| }); | |
| axios.get(url) | |
| .then(({ data, status }) => { | |
| this.setState({ |
This file contains hidden or 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 * as React from 'react'; | |
| export default () => ( | |
| <section> | |
| <h2>Bacon</h2> | |
| <p> | |
| Bacon ipsum dolor amet kielbasa swine jerky, beef ribs sausage turducken | |
| short ribs strip steak venison buffalo meatball tongue. T-bone short loin | |
| frankfurter capicola buffalo. Kevin ham hock chuck tail kielbasa short |
This file contains hidden or 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 { Router } from './routing'; | |
| import Nav from './Nav.jsx'; | |
| import * as pages from './pages'; | |
| const routes = new Map<string, React.ComponentType>([ | |
| ['/', () => <p>Pick an Ipsum!</p>], | |
| ['/lorem', pages.Lorem], | |
| ['/bacon', pages.Bacon], | |
| ['/hipster', pages.Hipster], | |
| ['/office', pages.Office], |
This file contains hidden or 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 { Link } from './routing'; | |
| interface NavProps { | |
| paths: string[]; | |
| } | |
| const getLinkText = (path: string) => | |
| `${path[1].toUpperCase()}${path.slice(2)}`; | |
| const Nav: React.FC<NavProps> = ({ paths }) => ( |
This file contains hidden or 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 * as React from 'react'; | |
| const App = () => ( | |
| <main> | |
| <h1>My App</h1> | |
| <React.Suspense fallback={<p>Loading...</p>}> | |
| <SomeSuspensefulComponent /> | |
| </React.Suspense> | |
| </main> | |
| ); |
This file contains hidden or 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 * as React from 'react'; | |
| const App = () => ( | |
| <main> | |
| <h1>My App</h1> | |
| <React.Suspense fallback={<LoadingSpinner />}> | |
| <Page /> | |
| <React.Suspense fallback={<MiniSpinner />}> | |
| <PageMetadata /> | |
| </React.Suspense> |
This file contains hidden or 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
| switch (status) { | |
| case Resolved: { | |
| const Component: T = result; | |
| return Component; | |
| } | |
| case Rejected: { | |
| const error: mixed = result; | |
| throw error; | |
| } | |
| case Pending: { |
This file contains hidden or 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 * as React from 'react'; | |
| const Lorem = React.lazy(() => import('./pages/Lorem')); | |
| const App = () => ( | |
| <React.Suspense fallback={<div className="loading-spinner" />}> | |
| <Lorem /> | |
| </React.Suspense> | |
| ); |
This file contains hidden or 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 * as React from 'react'; | |
| import Nav from './Nav.jsx'; | |
| import { Router } from './routing'; | |
| const routes = new Map<string, React.ComponentType>([ | |
| ['/', () => <p>Pick an Ipsum!</p>], | |
| ['/lorem', React.lazy(() => import('./pages/Lorem'))], | |
| ['/bacon', React.lazy(() => import('./pages/Bacon'))], | |
| ['/hipster', React.lazy(() => import('./pages/Hipster'))], | |
| ['/office', React.lazy(() => import('./pages/Office'))], |
This file contains hidden or 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
| 'use strict'; | |
| const indentWidth = 2; | |
| const selfClosingElements = [ | |
| 'meta', | |
| 'link', | |
| ]; | |
| const indent = (string, depth) => |