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