Skip to content

Instantly share code, notes, and snippets.

View patrickdent's full-sized avatar

Patrick patrickdent

View GitHub Profile
@patrickdent
patrickdent / create.sh
Created December 6, 2018 23:20
Create Resources
#!/usr/bin/env bash
gsutil mb gs://todo-assets
@patrickdent
patrickdent / deploy.sh
Created December 6, 2018 23:18
Deploy to the Cloud
#!/usr/bin/env bash
cd dist
echo "Deploying assets ..."
echo ""
gsutil cp "./browser.js" gs://todo-assets/browser.js
gsutil acl ch -u AllUsers:R gs://todo-assets/browser.js
echo "Deploying functions ..."
echo ""
@patrickdent
patrickdent / cloud.js
Created December 6, 2018 22:32
Full Isomorphic Render Script - Cloud
import fs from 'fs'
import path from 'path'
import React from 'react'
import ReactDOMServer from 'react-dom/server'
import * as Mobx from 'mobx'
import { Todos } from './components/Todos'
import { TodoState } from './state/TodoState'
// Here we simply define the state in a literal. For the sake of this demo,
// let's pretend that we needed to use an API key to access our todo list and
@patrickdent
patrickdent / cloud.js
Created December 6, 2018 19:23
Example Isomorphic Render
// ReactDOM.hydrate maps the redered React app to the source HTML so that React
// can take over managing the DOM. If the html generated from this rendering
// doesn't match the source HTML the app won't work properly and React will log
// an error.
ReactDOM.hydrate(<Todos state={state} />, document.getElementById('container'))
@patrickdent
patrickdent / cloud.js
Created December 6, 2018 19:01
Isomorphic React Cloud Script
import fs from 'fs'
import path from 'path'
import React from 'react'
import ReactDOMServer from 'react-dom/server'
import * as Mobx from 'mobx'
import { Todos } from './components/Todos'
import { TodoState } from './state/TodoState'
// Here we simply define the state in a literal. For the sake of this demo,
// let's pretend that we needed to use an API key to access our todo list and
@patrickdent
patrickdent / browser.js
Last active December 6, 2018 18:57
Isomorphic React Browser Script
import React from 'react'
import * as ReactDOM from 'react-dom'
import { Todos } from './components/Todos'
import { TodoState } from './state/TodoState'
// This script runs in the client browser.
// Retrieve and decode initial state from LocalStorage and build the Mobx state
// instance.
const rehydrateState = () => {