# Framework Patterns for `data-testid`
Copy-paste patterns for placing valid, unique, stable `data-testid` attributes. Follow the naming and stability rules in [data-testid-conventions.md](data-testid-conventions.md).
---
## React / JSX
```jsx
// Semantic markup FIRST (getByRole works), test IDs for durable handles.
function LoginForm({ onSubmit }) {
return (
);
}
```
Lists — stable entity key, never the index:
```jsx
function UserTable({ users }) {
return (
{users.map((user) => (
| {user.name} |
|
))}
);
}
```
Toggle swatch — a native `