import { Query } from 'components/renderCbs'; import { setCurrentTo, TSetCurrentTo } from 'actions/transaction'; import { AddressInputFactory } from './AddressInputFactory'; import React from 'react'; import { connect } from 'react-redux'; import { ICurrentTo } from 'selectors/transaction'; interface DispatchProps { setCurrentTo: TSetCurrentTo; } interface OwnProps { to: string | null; withProps(props: CallbackProps): React.ReactElement | null; } export interface CallbackProps { isValid: boolean; readOnly: boolean; currentTo: ICurrentTo; onChange(ev: React.FormEvent): void; } type Props = DispatchProps & OwnProps; class AddressFieldFactoryClass extends React.Component { public componentDidMount() { // this 'to' parameter can be either token or actual field related const { to } = this.props; if (to) { this.props.setCurrentTo(to); } } public render() { return ; } private setAddress = (ev: React.FormEvent) => { const { value } = ev.currentTarget; this.props.setCurrentTo(value); }; } const AddressFieldFactory = connect(null, { setCurrentTo })(AddressFieldFactoryClass); interface DefaultAddressFieldProps { withProps(props: CallbackProps): React.ReactElement | null; } const DefaultAddressField: React.SFC = ({ withProps }) => ( } /> ); export { DefaultAddressField as AddressFieldFactory };