Skip to content

Instantly share code, notes, and snippets.

View pgmoir's full-sized avatar
:octocat:
Working

Phil Moir pgmoir

:octocat:
Working
  • Captur Limited
  • UK
View GitHub Profile
@raphael-leger
raphael-leger / lazyWithRetry.js
Last active April 17, 2024 17:51
React LazyWithRetry
import { lazy } from 'react';
const lazyWithRetry = (componentImport) =>
lazy(async () => {
const pageHasAlreadyBeenForceRefreshed = JSON.parse(
window.localStorage.getItem(
'page-has-been-force-refreshed'
) || 'false'
);
@ChrisDobby
ChrisDobby / canvasDraw.jsx
Last active March 9, 2023 09:23
React component to redraw a canvas when resized
import React from "react";
const scaleWidth = 500;
const scaleHeight = 500;
function draw(canvas, scaleX, scaleY) {
const context = canvas.getContext("2d");
context.scale(scaleX, scaleY);
context.clearRect(0, 0, canvas.clientWidth, canvas.clientHeight);