membra-react

0.0.3 • Public • Published

membra-react

React-components for work with Membra

NPM version Build Status Dependency Status Coverage percentage experimental

Install

yarn add membra-react

Usage

import { Client } from "membra-react";

const membra = ...; // YOUR membra
const client = new Client(membra);
const Container = client.createContainer(({query})=>{
    return query.viewer.users({first:10}).edges.map(({node})=>{
        return {
            name: node.name,
        };
    });
});
const el = () => <Container 
    renderLoading={()=>{
        return <div>Loading...</div>
    }}
    renderFetched={(data)=>{
        return <div>{data.map((user)=>{
            return <div>User: {user.name}</div>;
        })}</div>;
    }}
    renderFailure={(error)=>{
        return <div>Error: {error}</div>;
    }} />;

API

interface IContainerProps<T> {
    vars?: { [varName: string]: any };
    renderFetched: (data: T) => React.ReactElement<any> | null;
    renderLoading: () => React.ReactElement<any> | null;
    renderFailure: (error: any) => React.ReactElement<any> | null;
}

type ContainerWrapper<T> = (props: IContainerProps<T>) => React.ReactElement<any>;

class Client<S>

constructor(protected membra: IMembraClient<S>);

createContainer<T>(execution: IExecution<S, T>): ContainerWrapper<T>;

Test

yarn
yarn test

Readme

Keywords

none

Package Sidebar

Install

npm i membra-react

Weekly Downloads

1

Version

0.0.3

License

ISC

Last publish

Collaborators

  • arvitaly