TxComponent.tsx 1.1 KB

123456789101112131415161718192021222324252627282930313233
  1. // Copyright 2017-2020 @polkadot/react-components authors & contributors
  2. // This software may be modified and distributed under the terms
  3. // of the Apache-2.0 license. See the LICENSE file for details.
  4. import React from 'react';
  5. export default class TxComponent<P, S> extends React.PureComponent<P, S> {
  6. protected button: any;
  7. constructor (props: P) {
  8. super(props);
  9. this.button = React.createRef();
  10. }
  11. protected sendTx = (): void => {
  12. // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment,@typescript-eslint/no-unsafe-member-access
  13. const { component } = this.button.current;
  14. if (component) {
  15. // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-unsafe-call
  16. component.current.send();
  17. }
  18. }
  19. protected submit = (): void => {
  20. // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment,@typescript-eslint/no-unsafe-member-access
  21. if (this.button && this.button.current && this.button.current.click) {
  22. // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-unsafe-call
  23. this.button.current.click();
  24. }
  25. }
  26. }