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
| #!/usr/bin/env bash | |
| gsutil mb gs://todo-assets |
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
| #!/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 "" |
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 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 |
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
| // 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')) | |
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 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 |
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 * 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 = () => { |