Skip to content

Instantly share code, notes, and snippets.

View matt-dunn's full-sized avatar

Matt Dunn matt-dunn

View GitHub Profile
/** !
* Copyright (c) 2020, Matt Dunn
*
* @author Matt Dunn (https://matt-dunn.github.io/)
* @licence MIT
*/
/**
* Optimised selector - similar to reselect
*
@matt-dunn
matt-dunn / app.js
Last active November 7, 2020 12:33
Pure JS implementation of JSX functional component rendering and state management
/** !
* Copyright (c) 2020, Matt Dunn
*
* @author Matt Dunn (https://matt-dunn.github.io/)
* @licence MIT
*/
/** @jsx h **/
// ===== State (Redux style) =====
@matt-dunn
matt-dunn / useLocalStorage.ts
Last active October 28, 2020 19:56
Simple local storage React hook
/** !
* Copyright (c) 2020, Matt Dunn
*
* @author Matt Dunn (https://matt-dunn.github.io/)
* @licence MIT
*/
import { useState } from "react";
function useLocalStorage<P>(key: string, initial?: P | undefined): [P | undefined, (newValue: P | undefined) => void] {
/** !
* Copyright (c) 2020, Matt Dunn
*
* @author Matt Dunn (https://matt-dunn.github.io/)
* @licence MIT
*/
/**
* Example of a dependency free flux style state implementation
* See https://github.com/matt-dunn/state/blob/master/app/index.tsx for a typescript