ghost-portal/packages/ui-app/src/TxComponent.tsx
kwingram25 dc943d7cd6
Button/TxButton submit on enter (#1170)
* Button/TxButton submit on enter

* promise linting

* testing ref approach

* Add TxComponent to handle submit on enter

* remove accountNonce

* remove input ref

* remove TxButton constructor

* remove comment

* empty constructor

* linting

* bug with null ref

* linting
2019-05-22 18:08:58 +02:00

28 lines
688 B
TypeScript

// Copyright 2017-2019 @polkadot/app-transfer 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 React from 'react';
export default class TxComponent<P, S> extends React.PureComponent<P, S> {
button: any;
constructor (props: P) {
super(props);
this.button = React.createRef();
}
sendTx = (): void => {
const { component } = this.button.current;
if (component) {
component.current.send();
}
}
submit = (): void => {
if (this.button && this.button.current && this.button.current.click) {
this.button.current.click();
}
}
}