Code · 1 file
Sample JSX File
JSX is JavaScript with HTML-like syntax for React components. The JSX 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.
JSX · 596 B
Sample JSX (React) file
An idiomatic JSX (React) 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 component — samplefiles.com
import { useState } from 'react';
export function CustomerList({ customers }) {
const [vipOnly, setVipOnly] = useState(false);
const shown = vipOnly ? customers.filter((c) => c.balance >= 10_000) : customers;
return (
<section>
<label>
<input type="checkbox" checked={vipOnly} onChange={(e) => setVipOnly(e.target.checked)} /> VIP only
</label>
<ul>
{shown.map((c) => (
<li key={c.id}>
{c.name}: ${c.balance.toFixed(2)}
</li>
))}
</ul>
</section>
);
}File details
Download from the command line
curl -L -o sample.jsx https://files.samplefiles.com/code/jsx/sample.jsxwget https://files.samplefiles.com/code/jsx/sample.jsxhttps://files.samplefiles.com/code/jsx/sample.jsxprintf '%s %s\n' ae42738d2356e7a25bf0f7edd6e2664211ada5d8f56697200e30ac4e88c9dbfa sample.jsx | shasum -a 256 -cOr check the download in your browser with the checksum calculator.