Skip to content

Instantly share code, notes, and snippets.

View dangdennis's full-sized avatar

Dennis Dang dangdennis

View GitHub Profile
@dangdennis
dangdennis / UserContext.tsx
Created December 27, 2020 07:23
Dynamic import of firebase in useEffect
// Assume useEffect is run along a <Context.Provider>
// function YourProvider() {
// <insert here our firebase useEffect from below>
// return <SomeContext.Provider />
// }
useEffect(() => {
async function run() {
const firebase = (await import("@/libs/firebase")).default;
const unsubscriber = firebase.auth().onAuthStateChanged(async (user) => {});
### Keybase proof
I hereby claim:
* I am dangdennis on github.
* I am dangggit (https://keybase.io/dangggit) on keybase.
* I have a public key ASCke7f_6v5Przwo7cej5G806Yq9MnI5tLWL-rwgLKKmlAo
To claim this, I am signing this object:
// http://jamesknelson.com/re-exporting-es6-modules/
@dangdennis
dangdennis / .hyper.js
Last active June 24, 2019 18:18
My hyperterm config
// Future versions of Hyper may add additional config options,
// which will not automatically be merged into this file.
// See https://hyper.is#cfg for all currently supported options.
module.exports = {
config: {
// choose either `'stable'` for receiving highly polished,
// or `'canary'` for less polished but more frequent updates
updateChannel: 'stable',
@dangdennis
dangdennis / Router.re
Last active June 12, 2019 23:33
Interop'ing a TS component into Reason
[@bs.module "./routes.js"] [@react.component]
external make: (~name: string) => React.element = "default";
@dangdennis
dangdennis / git-squash.md
Created December 10, 2018 18:39
How to squash recent commits
render: self =>
<div>
<ul>
<li> <Link href="/"> {str("Home")} </Link> </li>
<li> <Link href="/page1"> {str("Page 1")} </Link> </li>
<li> <Link href="/page2"> {str("Page 2")} </Link> </li>
<li> <Link href="/page3"> {str("Page 3")} </Link> </li>
<li> <Link href="/nested/page4"> {str("Nested Page")} </Link> </li>
<li> <Link href="/auth/*"> {str("Wild Card Auth Page")} </Link> </li>
</ul>
initialState: () => {route: Home},
/* Inside the make function of a React component */
didMount: self => {
let watchId =
/* Re.React gives us Router API */
ReasonReact.Router.watchUrl(url =>
self.send(
/* url.search, url.hash is also available */
switch (url.path) {
| [""]
/* Using Belt API for familiarity */
open Belt;
/* Will return an array of posts */
let fakeRealApi = "https://jsonplaceholder.typicode.com/posts";
/* Defining types for the expected posts */
type post = {
userId: int,
id: int,
/*
The fast pipe operator -> places the primary input in the FIRST argument position
Let's look at its use with Belt's List.map in a couple scenarios
*/
module FastPipe = {
/* Recall Belt's List.map signature
let map: (list('a), 'a => 'b) => list('b); */
let add5 = n => n + 5; /* callback func */
/* The list of integers are inserted as the first argument */