Morrys Repositories

Morrys Repositories

  • Docs
  • GitHub

›API Reference

Relay Hooks

  • Getting Started

API Reference

  • useFragment
  • useRefetchable
  • usePagination
  • useMutation
  • useSubscription
  • usePreloadedQuery

useSubscription

import { useMemo } from 'react';
import { useSubscription, graphql } from 'relay-hooks';

const subscriptionSpec = graphql`
  subscription TodoSubscription {
    todos {
      node {
        id
        text
        complete
      }
    }
  }
`;

const TodoList = (props) => {
  // NOTE: This will re-subscribe every render if config is not memoized. Please
  // do not pass an object defined inline.
  useSubscription(
    useMemo(() => ({
      subscription: subscriptionSpec,
      variables: {}
    }), [])
  );

  // ???
};
Last updated on 2/5/2021 by Adam Szaraniec
← useMutationusePreloadedQuery →
Morrys Repositories
Docs
about relay-hooks
Community
User Showcase
More
GitHubStar
Follow @m0rrys
Facebook Open Source
Copyright © 2022 Lorenzo Di Giacomo