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 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
Download from the command line
curl -L -o sample.tsx https://files.samplefiles.com/code/tsx/sample.tsxwget https://files.samplefiles.com/code/tsx/sample.tsxhttps://files.samplefiles.com/code/tsx/sample.tsxprintf '%s %s\n' 46a3c890c8f0168bc559d75f5e735a450f316a53f6e98a6a6a7e9a7bf0bea012 sample.tsx | shasum -a 256 -cOr check the download in your browser with the checksum calculator.