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
| { | |
| "short_name": "My First PWA", | |
| "name": "My First Progressive Web App", | |
| "icons": [ | |
| { | |
| "src":"icon.png", | |
| "sizes": "192x192", | |
| "type": "image/png" | |
| } | |
| ], |
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
| <!doctype html> | |
| <html lang="en"> | |
| <head> | |
| <meta charset="utf-8"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1"> | |
| <link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico"> | |
| <title>React App</title> | |
| <!-- Add in some basic styles for our HTML --> | |
| <style type="text/css"> | |
| body { |
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
| // Set this to true for production | |
| var doCache = false; | |
| // Name our cache | |
| var CACHE_NAME = 'my-pwa-cache-v1'; | |
| // Delete old caches that are not our current one! | |
| self.addEventListener("activate", event => { | |
| const cacheWhitelist = [CACHE_NAME]; | |
| event.waitUntil( |
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 React, { Component } from 'react'; | |
| import { Router, browserHistory, Route, Link } from 'react-router'; | |
| import logo from './logo.svg'; | |
| import './App.css'; | |
| const Page = ({ title }) => ( | |
| <div className="App"> | |
| <div className="App-header"> | |
| <img src={logo} className="App-logo" alt="logo" /> | |
| <h2>{title}</h2> |
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 React, {Component} from 'react' | |
| import Masonry from 'masonry-layout' | |
| import './ImageGrid.css' | |
| export default class ImageGrid extends Component{ | |
| state = { allImagesLoaded: false } | |
| imagesLoaded = 0 | |
| handleImageLoad = () => { | |
| this.imagesLoaded++ |
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 React from 'react' | |
| import { observer } from 'mobx-react' | |
| import { func, bool } from 'prop-types' | |
| // Separate local imports from dependencies | |
| import './styles/Form.css' | |
| // Declare propTypes here, before the component (taking advantage of JS function hoisting) | |
| // You want these to be as visible as possible | |
| ExpandableForm.propTypes = { | |
| onSubmit: func.isRequired, |
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 React, { Component } from 'react' | |
| import { observer } from 'mobx-react' | |
| import { string, object } from 'prop-types' | |
| // Separate local imports from dependencies | |
| import ExpandableForm from './ExpandableForm' | |
| import './styles/ProfileContainer.css' | |
| // Use decorators if needed | |
| @observer | |
| export default class ProfileContainer extends Component { |
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
| componentWillMount() { | |
| window.performance.mark('App') | |
| } | |
| componentDidMount() { | |
| console.log(window.performance.now('App')) | |
| } |
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 React, { Component } from 'react' | |
| export default class ListItem extends Component { | |
| shouldComponentUpdate(nextProps, nextState) { | |
| return nextProps.text !== this.props.text | |
| } | |
| render() { | |
| let { text } = this.props | |
| return <li>{text}</li> |
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
| componentDidUpdate() { | |
| Perf.stop() | |
| Perf.printInclusive() | |
| Perf.printWasted() | |
| } | |
| resetMultiplier() { | |
| Perf.start() | |
| this.setState({ multiplier: 2 }) | |
| } |