import React, { Component } from 'react'; import { Query } from 'components/renderCbs'; import { setCurrentValue, TSetCurrentValue } from 'actions/transaction'; import { connect } from 'react-redux'; import { AmountInput } from './AmountInputFactory'; import { AppState } from 'reducers'; export interface CallbackProps { isValid: boolean; readOnly: boolean; currentValue: | AppState['transaction']['fields']['value'] | AppState['transaction']['meta']['tokenValue']; onChange(ev: React.FormEvent); } interface DispatchProps { setCurrentValue: TSetCurrentValue; } interface OwnProps { value: string | null; withProps(props: CallbackProps): React.ReactElement | null; } type Props = DispatchProps & OwnProps; class AmountFieldClass extends Component { public componentDidMount() { const { value } = this.props; if (value) { this.props.setCurrentValue(value); } } public render() { return ; } private setValue = (ev: React.FormEvent) => { const { value } = ev.currentTarget; this.props.setCurrentValue(value); }; } const AmountField = connect(null, { setCurrentValue })(AmountFieldClass); interface DefaultAmountFieldProps { withProps(props: CallbackProps): React.ReactElement | null; } const DefaultAmountField: React.SFC = ({ withProps }) => ( } /> ); export { DefaultAmountField as AmountFieldFactory };