Skip to content

Instantly share code, notes, and snippets.

View jakejrichards's full-sized avatar

Jake Richards jakejrichards

  • Palantir
View GitHub Profile
import React, { useRef, useEffect } from 'react';
const ExternalScript = ({ src }) => {
const ref = useRef();
useEffect(() => {
const scriptEl = document.createElement("script");
scriptEl.src = src;
ref.current.append(scriptEl);
}, [src]);
import React from 'react';
const Hello = () => {
return (
<div>
<h1>Hello, Medium</h1>
{/* This doesn't work */}
<script src="//google.com/somescript.js"></script>
</div>
);
{
"hosting": {
"public": "build",
"ignore": [
"firebase.json",
"**/.*",
"**/node_modules/**"
],
"rewrites": [
{
{
"projects": {
"default": "firebase-hosting-demo"
}
}
import _ from "lodash"
import React from "react";
import { useDispatch, useSelector } from "react-redux";
import { Firestore } from "@google-cloud/firestore";
const firestore = new Firestore();
interface Person extends Entity {
name: string;
hairColor: string;
import React from "react";
import { useDispatch, useSelector } from "react-redux";
import { Firestore } from "@google-cloud/firestore";
const firestore = new Firestore();
interface Person extends Entity {
name: string;
hairColor: string;
}
const firestore = new Firestore();
interface Person extends Entity {
name: string;
hairColor: string;
}
export const PersonComponent = ({ personId }: Record<"personId", string>) => {
const name = useSelector<any, any>(state => state.people[personId].name);
const hairColor = useSelector<any, any>(
import _ from "lodash";
import { map, filter } from "lodash/fp";
import { useEffect } from "react";
import { Query } from "@google-cloud/firestore";
interface Entity {
id: string;
}
interface FirebaseHookHandlers {
import { useEffect } from "react";
import { DocumentReference } from "@google-cloud/firestore";
interface Entity {
id: string;
}
interface FirebaseHookHandlers {
subscribe: () => void;
error: (error: Error) => void;
import { DocumentSnapshot } from "@google-cloud/firestore";
interface Entity {
id: string;
}
const dataFromSnapshot = <T extends Entity>(
snapshot: DocumentSnapshot
): T | undefined => {
if (!snapshot.exists) return undefined;