Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Error:Error:line (104)Cannot create `Select` element because array type [1] is incompatible with `OptionType` [2] in the first argument of property `onChange`.
- Error:Error:line (104)Cannot create `Select` element because array type [1] is incompatible with null [2] in the first argument of property `onChange`.
- Error:Error:line (104)Cannot create `Select` element because array type [1] is incompatible with undefined [2] in the first argument of property `onChange`.
- // @flow
- import * as React from 'react';
- import Select from 'react-select';
- type LabelValueObject = Object & {
- value: string,
- label: string
- }
- type State = {
- options: LabelValueObject[],
- selectedOptions: LabelValueObject[],
- }
- export class ServiceDropdown extends React.Component<Props, State> {
- constructor(props: Props) {
- super(props);
- this.state = {
- options: [],
- selectedOptions: null,
- };
- }
- handleChange = (selectedOptions: LabelValueObject[]): void => {
- this.setState({ selectedOptions });
- };
- render() {
- const { selectedOptions } = this.state;
- return (
- <>
- <Select
- isMulti
- isSearchable
- onChange={this.handleChange} <=== flow error
- value={selectedOptions}
- options={this.state.options}
- />
- </>
- );
- }
- }
- export default ServiceDropdown;
- onChange: (ValueType, ActionMeta) => void,
- type ValueType = OptionType | OptionsType | null | void
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement