Skip to content

Instantly share code, notes, and snippets.

View dherault's full-sized avatar
🔥
Creating

David Hérault dherault

🔥
Creating
View GitHub Profile
@ChronSyn
ChronSyn / babel.config.js
Last active May 1, 2024 05:51
Expo - Alias path example
module.exports = function (api) {
api.cache(true);
return {
presets: ['babel-preset-expo'],
plugins: [
["@babel/plugin-transform-flow-strip-types"],
["@babel/plugin-proposal-decorators", { "legacy": true }],
["@babel/plugin-proposal-class-properties", { "loose": true }],
["module-resolver", {
"alias": {
import { MutableRefObject, useMemo } from 'react';
export const useForkedRef = <T = Element>(...refs: Array<MutableRefObject<T>>): (node: T) => void =>
useMemo(() => {
if (refs.every(ref => ref == null)) {
return null;
}
return node => {
refs.forEach(ref => {
@callumlocke
callumlocke / scale-canvas.ts
Last active April 12, 2024 03:25
How to fix a canvas so it will look good on retina/high-DPI screens.
/*
UPDATED for 2023 - Now much simpler. The old tricks are no longer needed.
The following code makes an 800×600 canvas that is always as sharp as possible for the device.
You still draw on it as if it's the logical size (800×600 in this case), but everything just
looks sharper on high-DPI screens. Regular non-sharp screens are not affected.
*/
const width = 800