Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View chasoft's full-sized avatar
🎯
Working from home

Brian Cao chasoft

🎯
Working from home
View GitHub Profile
@chasoft
chasoft / htm5-picture-tag.html
Created July 1, 2022 03:36
Sample for picture tag in html5
<picture>
<source
srcSet={`${mockupDesktop} 1x, ${mockupDesktop2x} 2x, ${mockupDesktop3x} 3x, ${mockupDesktop4x} 4x`}
media="(min-width: 768px)"
/>
<source
srcSet={`${mockupMobile} 1x, ${mockupMobile2x} 2x, ${mockupMobile3x} 3x, ${mockupMobile4x} 4x`}
media="(max-width: 767px)"
/>
<img
@chasoft
chasoft / useLocalComponentCache.js
Last active December 12, 2021 15:42
A simple hook to replace useState (when using with Object type)
/*
URL: https://anh.pw/do-not-use-usestate-directly-when-working-with-nested-object
Note:
- v1.2: support update, toggle and delete
- v1.0: support update and toggle
*/
import { get, set, cloneDeep } from "lodash"
import { useDeepCompareEffect } from "react-use"