Skip to content

Instantly share code, notes, and snippets.

Avatar

Robert Gonzales robertgonzales

View GitHub Profile
View keybase.md

Keybase proof

I hereby claim:

  • I am robertgonzales on github.
  • I am robricgon (https://keybase.io/robricgon) on keybase.
  • I have a public key whose fingerprint is F694 40F4 23C1 1109 3103 DC8A 4FFA 3FD9 09CF 172D

To claim this, I am signing this object:

@robertgonzales
robertgonzales / 1-helloworld.html
Last active Sep 14, 2018
React in the browser, no build step necessary.
View 1-helloworld.html
<html>
<head>
<title>React Hello World</title>
</head>
<body>
<div id="app"></div>
<script src="https://unpkg.com/react@16/umd/react.production.min.js"></script>
<script src="https://unpkg.com/react-dom@16/umd/react-dom.production.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/babel-standalone/6.26.0/babel.min.js"></script>
<script type="text/babel">
@robertgonzales
robertgonzales / await-all.js
Created Jan 11, 2018
Promise.all using only async await.
View await-all.js
const delay = ms => new Promise(r => setTimeout(r, ms))
async function AwaitAll() {
try {
const promises = [
delay(1000),
delay(250),
delay(500),
]
for (let p of promises) await p
@robertgonzales
robertgonzales / Frame.js
Created Dec 12, 2017
Use React portals to render inside shadow dom and iframes
View Frame.js
class Frame extends Component {
componentDidMount() {
this.iframeHead = this.node.contentDocument.head
this.iframeRoot = this.node.contentDocument.body
this.forceUpdate()
}
render() {
const { children, head, ...rest } = this.props
return (
@robertgonzales
robertgonzales / App.jsx
Last active Mar 26, 2020
How to make a custom Prompt (using getUserConfirmation) for React Router v4
View App.jsx
// use Prompt like normal... magic happens in getUserConfirmation
class App extends Component {
render () {
return (
<Router getUserConfirmation={getUserConfirmation}>
{...}
<Prompt
when={formIsHalfFilledOut}
message="Are you sure you want to leave?"
/>