Skip to content
Snippets Groups Projects
Select Git revision
  • 7af2ef7aa91c5ffbb7b5f44d8290b5f853ea474d
  • xx-network default protected
  • dependabot/npm_and_yarn/npm_and_yarn-38c118d439
  • add-turkish-translation
  • turkish-translations
  • sentry
  • qs
  • master protected
  • prod
  • old-upstream
  • staging
  • remove-metamask
  • squashed-commits
13 results

react-query

  • Clone with SSH
  • Clone with HTTPS
  • user avatar
    github-actions[bot] authored
    skip-checks: true
    3e67a1a3
    History

    @polkadot/react-query

    WARNING: This is an internal package to polkadot-js/apps so is not inteded (yet) for broad use. Since these are generic components, they will move to the polkadot-js/ui repo once deemed stable and usable.

    For the existing sharable components usable in external React-based projects, take a look at the polkadot-js/ui documentation

    Overview

    A collection of RxJS enabled React components that operate with the @polkadot/api-rx library. It automatically manages subscriptions on behalf of the developer, providing a number of unstyled components that can be used to construct UIs.

    Usage

    Basic usage entails creating a ContextProvider and just using the components. For instance, to display the current node time,

    import React from 'react';
    import ReactDOM from 'react-dom';
    
    import { Api, NodeTime } from '@polkadot/react-query';
    
    ...
    ReactDOM.render(
      <Api>
        <NodeTime />
      </Api>,
      document.querySelector('#container')
    );
    ...

    All components are provided unstyled making no assumptions on the actual use, however they all support (optionally) the label, className and style attributes, that can be used to style to component.

    ...
    ReactDOM.render(
      <Api>
        <NodeTime className='rx-time' label='current node time:' />
      </Api>,
      document.querySelector('#container')
    );
    ...