Skip to content

Instantly share code, notes, and snippets.

View segunadebayo's full-sized avatar
😃

Segun Adebayo segunadebayo

😃
View GitHub Profile
@segunadebayo
segunadebayo / records-and-dict.ts
Last active October 10, 2019 20:16 — forked from OliverJAsh/foo.ts
Records and dictionaries in TypeScript
/*
In JavaScript, objects can be used to serve various purposes.
To maximise our usage of the type system, we should assign different types to our objects depending
on the desired purpose.
In this blog post I will clarify two common purposes for objects known as records and dictionaries
(aka maps), and how they can both be used with regards to the type system.
@segunadebayo
segunadebayo / Button.jsx
Created September 11, 2019 21:15 — forked from diegohaz/Button.jsx
React Component Hooks API (from Reakit)
import React from "react";
import { useButton, mergeProps } from "reakit";
function Button(props) {
// useButton should be used when the props are being applied to a non-button element
const button = useButton();
return <div {...mergeProps(button, props)} />;
}
// return value of useButton
@segunadebayo
segunadebayo / NextGA.js
Created August 23, 2019 13:03
Add Google Analytics to NextJS
import NextHead from 'next/head'
import React from 'react'
import ReactGA from 'react-ga'
import Router from 'next/router'
// GA Tracking Id
const gaTrackingId = '[GOOGLE ANALYTICS TRACKING ID GOES HERE]'
Router.onRouteChangeComplete = () => {
@segunadebayo
segunadebayo / NextActiveLink.js
Last active August 18, 2019 22:01
Style active link in NextJS