emptygif
ભાષા: ગુજરાતી

બધી ભાષાઓ અને ફ્રેમવર્ક

React Router (framework mode, ex-Remix) TypeScript

React Router (framework mode, ex-Remix) માટે TypeScript સ્નિપેટ, જે /pixel.gif પરની રિક્વેસ્ટનો જવાબ empty GIF થી આપે છે. GIF સ્ટાર્ટઅપ વખતે એક જ વાર ડિકોડ થાય છે.

React Router (framework mode, ex-Remix) TypeScript

ઇન્સ્ટૉલ
npx create-react-router@latest
ફાઇલ
pixel.ts
ચલાવો
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',
    },
  });
}

અમે આ સ્નિપેટ ચલાવ્યો અને તેણે પરત કરેલા બાઇટની સરખામણી કરી.

ચકાસો

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

સત્તાવાર સાઇટ: React Router (framework mode, ex-Remix)

TypeScript માં વધુ