Why Flow doesn't accept the transfer functions of the component?


Warning: count(): Parameter must be an array or an object that implements Countable in /home/styllloz/public_html/qa-theme/donut-theme/qa-donut-layer.php on line 274
0 like 0 dislike
7 views
Good evening.
There is such a component :

// @flow import * as React from "react"; import { connect } from "react-redux"; import { searchAction, changeMode } from "../../actions"; import SearchForm from "../../presentational/SearchForm"; type State = { inputValue: string }; type Props = { searchAction: (inputValue?: string) => mixed changeMode: (val?: string) => mixed }; class Search extends React.Component { constructor(props: Props) { super(props); this.state = { inputValue: " }; } handleSubmit = (e: SyntheticEvent<>) => { e.preventDefault(); let { inputValue } = this.state; this.props.searchAction(inputValue); }; handleRadioChange = (e: SyntheticInputEvent<>) => { this.props.changeMode(e.target.value); }; inputHandle = (e: SyntheticInputEvent<>) => { this.setState({ inputValue: e.target.value }); }; render() { return ( ); } } mapStateToProps function(state) { return {}; } const mapDispatchToProps = { searchAction, changeMode }; export default connect(mapStateToProps, mapDispatchToProps)(Search);


Errors occur in three places :
inputHandle={this.inputHandle} radioChangeHandle={this.handleRadioChange} submitHandle={this.handleSubmit}

Code :
Cannot create `SearchForm` element because the `SyntheticInputEvent` [1] string is incompatible with [2] in the first argument of property `inputHandle`.
How to fix?

UPD: SearchForm.js :
//@flow import React from "react"; type Props = { title: string, inputHandle: (value: string) => mixed radioChangeHandle: (value: string) => mixed submitHandle: (value: string) => mixed }; const SearchForm = ({ title inputHandle, radioChangeHandle, submitHandle }: Props) => { return ( {title}{" "} Image {" "} Video ); }; export default SearchForm;

GITHUB
by | 7 views

2 Answers

0 like 0 dislike
In addition to the comment, try this: SyntheticInputEvent
by
0 like 0 dislike
Solution :
type Props = { title: string, inputHandle: (value: SyntheticInputEvent<>) => mixed radioChangeHandle: (value: SyntheticInputEvent<>) => mixed submitHandle: (value: SyntheticEvent<>) => mixed };


Updated the props in SearchForm.js
by

Related questions

0 like 0 dislike
2 answers
0 like 0 dislike
2 answers
0 like 0 dislike
1 answer
110,608 questions
257,186 answers
0 comments
35,390 users