Say goodbye to code shuffling to satisfy useCallback's dependencies.
Simple variant:
export const useStableCallback = (userFn) => {
const userFnRef = useRef();
userFnRef.current = userFn;
const wrapperFnRef = useRef();
| { | |
| "type": "excalidraw", | |
| "version": 2, | |
| "source": "https://excalidraw.com", | |
| "elements": [ | |
| { | |
| "id": "hz1wSxPkfpxf1xd7LPSoV", | |
| "type": "rectangle", | |
| "x": 785, | |
| "y": 195, |
Say goodbye to code shuffling to satisfy useCallback's dependencies.
Simple variant:
export const useStableCallback = (userFn) => {
const userFnRef = useRef();
userFnRef.current = userFn;
const wrapperFnRef = useRef();
Boomarklets for fetching/pushing to PRs from forked repositories. Click on them when viewing a PR to copy to clipboard a git command.
Copy each of the codeblocks to separate bookmarks as urls:
fetch:
javascript:if(location.href.includes("github.com")&&location.href.includes("/pull"))try{const e=document.querySelector(".gh-header-meta .TableObject-item--primary"),t=e.querySelector(".commit-ref:not(.head-ref) a[href]"),c=e.querySelector(".commit-ref.head-ref a[href]"),r=t.href,o=c.href,[,i,h="master"]=o.match(/^(.*?)\/tree\/(.+).*$/)||o.match(/^(.*?github.com\/.*?)$/);navigator.clipboard.writeText(o.includes(r)?`git checkout master && git pull && git checkout ${h}`:`git branch -d FETCH_HEAD; git fetch ${i} ${h} && git checkout FETCH_HEAD`)}catch(e){console.log(e)}