useResolve: ids for whatever the user typed
| typed | team_id |
|---|---|
| KC | 12 |
| Kansas City Chiefs | 12 |
| OAK | 13 |
| Las Vegas Raiders | 13 |
| SD | 24 |
import { useResolve } from "@sportsdataverse/sdvplot/react";
import type { ReactElement } from "react";
const typed = ["KC", "Kansas City Chiefs", "OAK", "Las Vegas Raiders", "SD"];
function Resolved(): ReactElement | null {
const resolve = useResolve("nfl"); // undefined until the league has loaded, then a sync resolver
if (resolve === undefined) return null;
return (
<table>
<thead>
<tr>
<th>typed</th>
<th>team_id</th>
</tr>
</thead>
<tbody>
{typed.map((v) => (
<tr key={v}>
<td>{v}</td>
<td>{resolve(v) ?? "-"}</td>
</tr>
))}
</tbody>
</table>
);
}
<Resolved />;
Tags: react · useResolve · resolve · nfl. All sdvplot examples.