javascript Componente basico没有反应realizando查询没有graphql

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了javascript Componente basico没有反应realizando查询没有graphql相关的知识,希望对你有一定的参考价值。

import React from "react";
import gql from "graphql-tag";
import { useQuery } from "react-apollo-hooks";

const currency = "AUD";
// GraphQL Query
const GET_RATES = gql`
  query GetRates($currency: String!) {
    rates(currency: $currency) {
      name
      currency
      value: rate
    }
  }
`;

function Example() {
  const { data, error, loading } = useQuery(GET_RATES, {
    variables: { currency }
  });
  if (loading) {
    return <h1> Loading rates...</h1>;
  }
  if (error) {
    return <h1>Something went wrong: {error}</h1>;
  } else {
    const renderRates = data.rates.map(rate => (
      <li key={rate.currency}>
        You need {rate.value}
        {rate.currency} to get 1 {currency}
      </li>
    ));
    return <ul>{renderRates}</ul>;
  }
}

export default Example;

以上是关于javascript Componente basico没有反应realizando查询没有graphql的主要内容,如果未能解决你的问题,请参考以下文章

javascript Componente basico没有反应realizando查询没有graphql

markdown Componente Ventana

text 0UIControl hacer clicable cualquier componente

html un componente para hacer el test.vue

html Este es un ejerciciodecómoconsitirun componente con React usando clases。

html Este es un ejerciciodecómoconsitirun componente con React usando funciones。