How to use the rest-hooks.useResultCache function in rest-hooks

To help you get started, we’ve selected a few rest-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 HandshakeAlliance / HNScan / src / screens / Names.js View on Github external
function NamesContainer(props) {
  const pageOffset = (props.page - 1) * 25;
  const names = useResource(NameResource.listShape(), { offset: pageOffset });
  const { limit, total } = useResultCache(NameResource.listShape(), {
    offset: pageOffset
  });
  const pages = Math.ceil(total / limit);
  const nameRows = names.map((name, index) => (
    
  ));

  // 25 blocks per page
  return (
    <>
      
        
          TLD Names
github HandshakeAlliance / HNScan / src / components / TransactionList / TransactionList.js View on Github external
const TransactionList = ({ url, page, from }) => {
  //@todo these will come from filtering options.
  const limit = 10;
  const offset = (page - 1) * limit;
  from.limit = limit;
  from.offset = offset;
  const txs = useResource(TransactionResource.listShape(), from);
  const { total } = useResultCache(TransactionResource.listShape(), from);
  const pages = Math.ceil(total / limit);
  const renderTransactions = txs.map((tx, index) => (
    
      
        Tx {index + 1}: {tx.hash}
      
      <div>
        <div>
          
        </div>
        <div>
          
        </div>
      </div>
    
  ));
github HandshakeAlliance / HNScan / src / screens / Blocks.js View on Github external
function BlocksView({ page }) {
  const pageOffset = (page - 1) * 25;
  const blocks = useResource(BlockResource.listShape(), { offset: pageOffset });
  const { limit, total } = useResultCache(BlockResource.listShape(), {
    offset: pageOffset
  });
  const pages = Math.ceil(total / limit);
  return (
    &lt;&gt;
      
        
          HNS Blocks
        
        
          
        
      
      
    
  );
github HandshakeAlliance / HNScan / src / screens / Name.js View on Github external
function NameView({ name, page, changePage, url }) {
  //Run these in parallel
  const nameData = useResource(NameResource.detailShape(), { name });
  //@todo move this to NameHistory component, since we want to be able to filter it effectively.
  const history = useResource(NameHistoryResource.listShape(), { name });
  const { limit, total } = useResultCache(NameHistoryResource.listShape(), {
    name
  });
  const pages = Math.ceil(total / limit);
  return (
    &lt;&gt;
      
      
      {name.records &amp;&amp; }
      
    
  );
github HandshakeAlliance / HNScan / src / screens / Blocks / BlocksContainer.js View on Github external
export default function BlocksContainer(props) {
  const pageOffset = (props.page - 1) * 25;
  const blocks = useResource(BlockResource.listShape(), { offset: pageOffset });
  const { limit, total } = useResultCache(BlockResource.listShape(), {
    offset: pageOffset
  });
  const pages = Math.ceil(total / limit);
  return (
    
  );
}