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 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 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 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 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 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 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 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
body { | |
font-family: "Helvetica Neue",Helvetica,Arial,sans-serif; | |
} | |
#root { | |
background-color: #f5f8fa; | |
height: 100%; | |
min-height: 100vh; | |
padding: 20px 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 { observable } from 'mobx' | |
class ContactStore { | |
@observable contacts = [] | |
load() { | |
fetch(API_URL + '/contacts') | |
.then(data => { | |
const list = data.contacts.map(contactData => { | |
return new Contact(contactData) |
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 { toJS, observable } from 'mobx' | |
class Contact { | |
id = 0 | |
@observable name = '' | |
@observable number = '' | |
constructor(data) { | |
this.name = data.name | |
this.number = data.number |
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 React from 'react' | |
import { Provider } from 'mobx-react' | |
// Importing our own stores | |
import { UserStore, ContactStore } from '../stores' | |
const state = { | |
userStore: UserStore, | |
contactStore: ContactStore | |
} |