/react-hasura-resource

Primary LanguageTypeScriptMIT LicenseMIT

NPM Version Package License NPM Downloads Minified Size Minzipped Size

Description

React Hasura Resource

Installation

$ yarn add react-hasura-resource

Example

import { ReactHasuraResourceContext } from 'react-hasura-resource';

const hasuraResourceConfig: HasuraResourceContextState = {
  endpoint: 'https://react-hasura-resource-data.herokuapp.com',
  config: {
    primaryKey: {}
  }
}

const App = () => (
  <HasuraResourceContext.Provider value={hasuraResourceConfig}>
    <HasuraResourceList
      tableName="student"
      render={({ data, status }) => (
        status === 'success' ? (
          <ul>
            {data?.map(student => (
              <li key={student.id}>{student.name}</li>
            ))}
          </ul>
        ) : (
          <p>Loading...</p>
        )
      )}
    />
  </HasuraResourceContext.Provider>
)