0.0.5 • Published 4 years ago

react-cell v0.0.5

Weekly downloads
-
License
MIT
Repository
-
Last release
4 years ago

react-cell

Inspired by Redwood Cells, using Apollo Client.

Getting started

yarn add react-cell

Features

  • First-class TypeScript support

Usage

import cell from 'react-cell';
import { gql } from '@apollo/client';

interface NovelCellProps {
  title: string;
}

const QUERY = gql`
query($title: String) {
  novel(title: $title) {
    title
    description
  }
}`;

const NovelCell = cell<{ novel: Novel }, NovelCellProps>(QUERY, {
  Success({ novel: Novel }) {
    return (
      <div>
        <h1>{novel.title}</h1>
        <h1>{novel.description}</h1>
      </div>
    );
  },

  Loading() {
    return (
      <div>Loading...</div>
    ); 
  },

  Empty() {
    return (
      <div>Found nothing.</div>
    ); 
  },

  Failure({ error }) {
    return (
      <div>Error: {error.message}</div>
    ); 
  }
});

<NovelCell title="Title here">
0.0.5

4 years ago

0.0.4

4 years ago

0.0.3

4 years ago

0.0.2

4 years ago

0.0.1

4 years ago