Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 | 3x 3x 1x 3x 2x 2x 2x 1x 1x 1x 1x | // @flow import * as React from 'react'; import { connect } from 'react-redux'; import { setInput, getSuggestions, clearSuggestions, } from '../actions/formActions'; import { getGifs } from '../actions/resultActions'; type Props = { dispatchInput: Function, dispatchSubmit: Function, inputValue: string, chosen: string, }; type State = {}; export class SearchForm extends React.Component<Props, State> { render() { const { dispatchInput, chosen, dispatchSubmit, inputValue } = this.props; return ( <> {chosen === '' && ( <form action="" onSubmit={dispatchSubmit}> <button type="submit" className="gifpicker__submit"></button> <input placeholder="input search text" onChange={dispatchInput} value={inputValue} className="gifpicker__input" /> </form> )} </> ); } } export const mapStateToProps = (state: Object) => ({ apikey: state.settings.apikey, inputValue: state.form.input, chosen: state.result.chosen, }); export const mapDispatchToProps = (dispatch: Function) => ({ dispatchInput: (e: Object) => { const { value } = e.target; dispatch(setInput(value)); if (value.length >= 3) { dispatch(getSuggestions()); } else { dispatch(clearSuggestions()); } }, dispatchSubmit: (e: Object) => { e.preventDefault(); dispatch(getGifs()); }, }); export default connect<*, *, *, *, *, *>( mapStateToProps, mapDispatchToProps )(SearchForm); |