import React, { Component } from 'react'; import { connect } from 'react-redux'; import { sanitizeNumericalInput } from 'libs/values'; import { AppState } from 'features/reducers'; import { transactionFieldsActions } from 'features/transaction'; import { NonceInputFactory } from './NonceInputFactory'; export interface CallbackProps { nonce: AppState['transaction']['fields']['nonce']; readOnly: boolean; shouldDisplay: boolean; onChange(ev: React.FormEvent): void; } interface DispatchProps { inputNonce: transactionFieldsActions.TInputNonce; } interface OwnProps { withProps(props: CallbackProps): React.ReactElement | null; } type Props = OwnProps & DispatchProps; class NonceFieldClass extends Component { public render() { return ; } private setNonce = (ev: React.FormEvent) => { const { value } = ev.currentTarget; this.props.inputNonce(sanitizeNumericalInput(value)); }; } export const NonceFieldFactory = connect(null, { inputNonce: transactionFieldsActions.inputNonce })(NonceFieldClass);