// Copyright 2017-2019 @polkadot/react-api authors & contributors // This software may be modified and distributed under the terms // of the Apache-2.0 license. See the LICENSE file for details. import { DefaultProps, Options } from './types'; import { BaseProps } from '../types'; import React from 'react'; import withCall from './call'; interface Props extends BaseProps { callResult?: T; } // eslint-disable-next-line @typescript-eslint/explicit-function-return-type export default function withCallDiv (endpoint: string, options: Options = {}) { return (render: (value?: T) => React.ReactNode, defaultProps: DefaultProps = {}): React.ComponentType => { class Inner extends React.PureComponent> { public render (): React.ReactNode { const { callResult, callUpdated, children, className = defaultProps.className, label = '', style } = this.props; return (
{label}{render(callResult)}{children}
); } } return withCall(endpoint, { ...options, propName: 'callResult' })(Inner); }; }