Repository URL to install this package:
|
Version:
0.0.13 ▾
|
import * as React from 'react';
import { createContext } from 'react';
import { Query } from 'react-apollo';
// import {
// } from '@skava/graphql-bindings'
import { Placeholder } from '@skava/packages/ui';
import { GetList, } from './state/list/queries';
import { favoritesContainer } from './state';
export const GetListContext = createContext({});
export class GetListProvider extends React.PureComponent {
constructor() {
super(...arguments);
/**
* @todo typings & split to dep
*/
this.handleChange = data => {
const GetListData = data && data.getList;
return favoritesContainer.update(GetListData);
};
this.renderProps = gqlProps => {
const GetListData = gqlProps.data && gqlProps.data.getList;
if (gqlProps.loading) {
return React.createElement(Placeholder, null);
}
else if (GetListData === undefined) {
return React.createElement(Placeholder, null);
}
else {
return (React.createElement(GetListContext.Provider, { value: GetListData }, this.props.children));
}
};
}
render() {
// const variables = this.props.variables || {}
const variables = {
listId: favoritesContainer.favoriteListID,
pageParams: {
page: 1,
size: 50,
}
};
return (React.createElement(Query, { query: GetList, variables: variables, "fetch-policy": 'network-only',
// pollInterval={3000}
onCompleted: this.handleChange }, this.renderProps));
}
}
//# sourceMappingURL=GetListContext.js.map