emptygif
Harshe: Hausa

Duk harsuna da frameworks

React Router (framework mode, ex-Remix) TypeScript

Snippet na TypeScript don React Router (framework mode, ex-Remix) da ke amsa requests zuwa /pixel.gif da empty GIF, wanda ake decoding ɗinsa sau ɗaya lokacin farawa.

React Router (framework mode, ex-Remix) TypeScript

Girkawa
npx create-react-router@latest
Fayil
pixel.ts
Gudanar
npm run dev
// app/routes.ts:  route('/pixel.gif', 'routes/pixel.ts')
// app/routes/pixel.ts - a resource route: a loader and no default export.
const GIF = Uint8Array.from(atob('R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw=='), (c) => c.charCodeAt(0));

export function loader() {
  return new Response(GIF, {
    headers: {
      'Content-Type': 'image/gif',
      'Content-Length': String(GIF.length),
      'Cache-Control': 'no-store',
    },
  });
}

Mun gudanar da wannan snippet kuma mun kwatanta bytes ɗin da ya mayar.

Duba shi

curl -sI http://localhost:8080/pixel.gif

Shafin hukuma: React Router (framework mode, ex-Remix)

Ƙari a TypeScript