Code · 1 file

Sample TSX File

TSX is TypeScript with JSX, the usual file type of typed React components. The TSX sample is a small program — a customer record, a VIP check and a formatted total — that is the same in every language we offer, so you can compare them side by side.

TSX · 788 B

Sample TSX (React + TypeScript) file

An idiomatic TSX (React + TypeScript) example: a customer record type, a VIP check, a total and a formatted loop — the same program in every language we offer.

CC0 · free for any use · Verified by an independent tool · Report a problem

sample.tsx — first linesTSX
// Sample React + TypeScript component — samplefiles.com
import { useMemo, useState } from 'react';

type Customer = { id: number; name: string; balance: number };

export function CustomerTable({ customers }: { customers: Customer[] }) {
  const [query, setQuery] = useState('');
  const filtered = useMemo(
    () => customers.filter((c) => c.name.toLowerCase().includes(query.toLowerCase())),
    [customers, query],
  );

  return (
    <>
      <input value={query} onChange={(e) => setQuery(e.target.value)} placeholder="Search" />
      <table>
        <tbody>
          {filtered.map((c) => (
            <tr key={c.id}>
              <td>{c.name}</td>
              <td>{c.balance.toFixed(2)}</td>
            </tr>
          ))}
        </tbody>
      </table>

File details

Size
788 B (788 bytes)
MIME type
text/plain
SHA-256
46a3c890c8f0168bc559d75f5e735a450f316a53f6e98a6a6a7e9a7bf0bea012
MD5
9e024e12388b4b9d87c48b217b190c30

Download from the command line

curl -L -o sample.tsx https://files.samplefiles.com/code/tsx/sample.tsx

Or check the download in your browser with the checksum calculator.