const { data, loading, error } = useCurrencies();
function CurrencySelector({ onChange }: { onChange: (currency: Erc20) => void }) {
const { data: currencies, error, loading } = useCurrencies();
if (loading) return <Loader />;
if (error) return <Error message={error.message} />;
const handleChange = (event: React.ChangeEvent<HTMLSelectElement>) => {
const currency = currencies.find((c) => c.symbol === event.target.value);
if (currency) onChange(currency);
};
return (
<select onChange={handleChange}>
{currencies.map((c) => (
<option key={c.address} value={c.symbol}>
{c.name}
</option>
))}
</select>
);
}
useCurrencies
is a paginated hook that lets you fetch ERC20 tokens that are enabled on the Lens protocol.Pro-tip: use this hook to populate a dropdown menu of currencies to choose from to support for example a collect open action form or setup follow policy fees.