How to use the relay-hooks.useQuery function in relay-hooks

To help you get started, we’ve selected a few relay-hooks examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github relay-tools / relay-hooks / examples / relay-hook-example / todo / js / app.js View on Github external
const LayoutTodo = ({userId}) => {
  console.log('LayoutTodo', userId, isServer);
  const {props, error, retry, cached} = useQuery(
    QueryApp,
    {userId},
    {
      fetchPolicy: 'store-and-network',
    },
  );
  /*const { props, error, retry, cached } = useQuery({
    query: QueryApp,
    variables: {
      // Mock authenticated ID that matches database
      userId,
    },
    dataFrom: "STORE_THEN_NETWORK"
  });*/

  console.log('renderer', props, cached);
github relay-tools / relay-hooks / examples / relay-hook-example / nextjs-ssr / pages / index.tsx View on Github external
const Home = () => {
  const {error, cached, props, retry} = useQuery(
    query,
    variables,
    {
      fetchPolicy: STORE_OR_NETWORK,
    },
  );
  if (props) {
    return ;
  } else if (error) {
    return <div>{error.message}</div>;
  }
  return <div>loading</div>;
};
github relay-tools / relay-hooks / examples / relay-hook-example / nextjs-ssr / pages / you.tsx View on Github external
const Home = () =&gt; {
  const {error, cached, props, retry} = useQuery(
    query,
    variables,
    {
      fetchPolicy: STORE_OR_NETWORK,
    },
  );
  if (props) {
    return ;
  } else if (error) {
    return <div>{error.message}</div>;
  }
  return <div>loading</div>;
};