@makerinc/react-sdk
    Preparing search index...

    Function useMarkets

    • Hook to fetch available markets (regions/locales)

      Returns market choices as a discriminated union:

      • { type: "Currencies", value: { suggestedCurrency, availableCurrencies } }
      • { type: "Countries", value: { suggestedCountry, availableCountries } }
      • { type: "NotSupported" }
      • null

      Parameters

      Returns UseQueryResult<GetMarketsResponse>

      function MarketSelector() {
      const { data, isLoading } = useMarkets();

      if (isLoading) return <div>Loading...</div>;
      if (!data?.choices) return <div>Markets not available</div>;

      const choice = data.choices;

      if (choice.type === 'Currencies') {
      return (
      <select defaultValue={choice.value.suggestedCurrency}>
      {choice.value.availableCurrencies.map(currency => (
      <option key={currency} value={currency}>{currency}</option>
      ))}
      </select>
      );
      }

      if (choice.type === 'Countries') {
      return (
      <select defaultValue={choice.value.suggestedCountry}>
      {choice.value.availableCountries.map(country => (
      <option key={country} value={country}>{country}</option>
      ))}
      </select>
      );
      }

      return <div>Market selection not supported</div>;
      }