relay-decorators
Utility decorators for Relay components.
Guide
Installation
$ npm install relay-decorators
@poll(interval)
The @poll
decorator sets up a wrapper component that uses setInterval
to repeatedly call props.relay.forceFetch
at a fixed interval (specified in milliseconds). This is not an ideal way to get updating data from a GraphQL server, but is convenient if you don't have proper subscriptions.
;;; // type Widget {// size: Int// } @ // Poll every second.Component static propTypes = widget: ReactPropTypesobjectisRequired ; { return <div>The current widget size is: thispropswidgetsize</div> ; } ;
If a polling component has a parent with the same poll interval, the @poll
decorator will coalesce the poll timeouts to enable the queries to be batched.