React-select: Imcompatible with Flow 0.99.0 and newer

Created on 7 Jun 2019  ยท  5Comments  ยท  Source: JedWatson/react-select

Hello! Sorry for removing the issue template.

I upgraded my project to Flow 0.99.0 from 0.98.1, and discovered that it throws new errors for this library.

Would you accept a PR fixing them?

It seems we hit this new feature from 0.99.0

Fix an issue where Flow would not catch certain errors involving React function components with unannotated props.

Errors:

Error โ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆ node_modules/react-select/src/Select.js:442:23

Cannot assign defaultComponents(...) to this.components because:
 โ€ข property children is missing in props [1] but exists in object type [2] in property Menu.
 โ€ข property innerRef is missing in props [1] but exists in object type [2] in property Menu.

     node_modules/react-select/src/Select.js
     439โ”‚     document.removeEventListener('scroll', this.onScroll, true);
     440โ”‚   }
     441โ”‚   cacheComponents = (components: SelectComponents) => {
     442โ”‚     this.components = defaultComponents({ components });
     443โ”‚   };
     444โ”‚   // ==============================
     445โ”‚   // Consumer Handlers

     node_modules/react-select/src/components/Menu.js
 [2] 225โ”‚ export type MenuProps = MenuAndPlacerCommon & {
     226โ”‚   /** Reference to the internal element, consumed by the MenuPlacer component */
     227โ”‚   innerRef: ElementRef<*>,
     228โ”‚   /** The children to be rendered. */
     229โ”‚   children: ReactElement<*>,
     230โ”‚ };

     node_modules/react-select/src/components/index.js
 [1]  64โ”‚   Menu: ComponentType<MenuProps>,


Error โ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆ node_modules/react-select/src/animated/MultiValue.js:12:10

Cannot return function because:
 โ€ข property in is missing in props [1].
 โ€ข property onExited is missing in props [1].

      9โ”‚ const AnimatedMultiValue = (
     10โ”‚   WrappedComponent: AbstractComponent<MultiValueProps>
 [1] 11โ”‚ ): AbstractComponent<MultiValueProps> => {
     12โ”‚   return ({ in: inProp, onExited, ...props }) => (
     13โ”‚     <Collapse in={inProp} onExited={onExited}>
     14โ”‚       <WrappedComponent cropWithEllipsis={inProp} {...props} />
     15โ”‚     </Collapse>
     16โ”‚   );
     17โ”‚ };
     18โ”‚
     19โ”‚ export default AnimatedMultiValue;


Error โ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆ node_modules/react-select/src/animated/Placeholder.js:11:4

Cannot create Fade element because:
 โ€ข property in is missing in props [1] but exists in BaseTransition [2].
 โ€ข property onExited is missing in props [1] but exists in BaseTransition [2].

     node_modules/react-select/src/animated/Placeholder.js
      8โ”‚ const AnimatedPlaceholder = (
      9โ”‚   WrappedComponent: AbstractComponent<PlaceholderProps>
     10โ”‚ ): AbstractComponent<PlaceholderProps> => (props) => (
 [1] 11โ”‚   <Fade
     12โ”‚     component={WrappedComponent}
     13โ”‚     duration={props.isMulti ? collapseDuration : 1}
     14โ”‚     {...props}
     15โ”‚   />
     16โ”‚ );
     17โ”‚
     18โ”‚ export default AnimatedPlaceholder;

     node_modules/react-select/src/animated/transitions.js
 [2] 18โ”‚ type FadeProps = BaseTransition & {


Error โ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆ node_modules/react-select/src/animated/SingleValue.js:12:4

Cannot create Fade element because:
 โ€ข property duration is missing in props [1] but exists in object type [2].
 โ€ข property in is missing in props [1] but exists in BaseTransition [3].
 โ€ข property onExited is missing in props [1] but exists in BaseTransition [3].

        node_modules/react-select/src/animated/SingleValue.js
         9โ”‚ const AnimatedSingleValue = (
        10โ”‚   WrappedComponent: AbstractComponent<SingleValueProps>
        11โ”‚ ): AbstractComponent<SingleValueProps> => (props) => (
    [1] 12โ”‚   <Fade component={WrappedComponent} {...props} />
        13โ”‚ );
        14โ”‚
        15โ”‚ export default AnimatedSingleValue;

        node_modules/react-select/src/animated/transitions.js
 [3][2] 18โ”‚ type FadeProps = BaseTransition & {
        19โ”‚   component: ComponentType<any>,
        20โ”‚   duration: number,
        21โ”‚ };


Error โ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆ node_modules/react-select/src/animated/index.js:14:10

Cannot return object literal because:
 โ€ข property children is missing in props [1] but exists in object type [2] in property Menu.
 โ€ข property innerRef is missing in props [1] but exists in object type [2] in property Menu.

     node_modules/react-select/src/animated/index.js
      11โ”‚ const makeAnimated = (externalComponents?: SelectComponents= {}): SelectComponents => {
      12โ”‚   const components = defaultComponents({ components: externalComponents });
      13โ”‚   const { Input, MultiValue, Placeholder, SingleValue, ValueContainer, ...rest } = components;
      14โ”‚   return {
      15โ”‚     Input: AnimatedInput(Input),
      16โ”‚     MultiValue: AnimatedMultiValue(MultiValue),
      17โ”‚     Placeholder: AnimatedPlaceholder(Placeholder),
      18โ”‚     SingleValue: AnimatedSingleValue(SingleValue),
      19โ”‚     ValueContainer: AnimatedValueContainer(ValueContainer),
      20โ”‚     ...rest,
      21โ”‚   };
      22โ”‚ };
      23โ”‚
      24โ”‚ const AnimatedComponents = makeAnimated();

     node_modules/react-select/src/components/Menu.js
 [2] 225โ”‚ export type MenuProps = MenuAndPlacerCommon & {
     226โ”‚   /** Reference to the internal element, consumed by the MenuPlacer component */
     227โ”‚   innerRef: ElementRef<*>,
     228โ”‚   /** The children to be rendered. */
     229โ”‚   children: ReactElement<*>,
     230โ”‚ };

     node_modules/react-select/src/components/index.js
 [1]  64โ”‚   Menu: ComponentType<MenuProps>,
issubug-unconfirmed issuhas-pr issureviewed

Most helpful comment

In case it helps anyone - we've recently ran into this on a project were integrating the react-select library, and as a temporary fix added the following to the .flowconfig:

[ignore]
.*/node_modules/react-select/.*

However this results in another error where importing the library:

Error โ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆ src/components/Select/index.js:3:44

Cannot resolve module react-select.

     1โ”‚ // @flow
     2โ”‚ import React from 'react';
     3โ”‚ import Select from 'react-select';

So in addition to the above, mark the import line with $FlowFixMe (all this until #3626 is resolved).

All 5 comments

@montogeek would deeply appreciate a PR to fix this, thanks for raising the issue

In case it helps anyone - we've recently ran into this on a project were integrating the react-select library, and as a temporary fix added the following to the .flowconfig:

[ignore]
.*/node_modules/react-select/.*

However this results in another error where importing the library:

Error โ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆ src/components/Select/index.js:3:44

Cannot resolve module react-select.

     1โ”‚ // @flow
     2โ”‚ import React from 'react';
     3โ”‚ import Select from 'react-select';

So in addition to the above, mark the import line with $FlowFixMe (all this until #3626 is resolved).

Further to @breadadams comment, we've found that using untyped in our .flowconfig is working well and doesn't require the additional $FlowFixMe's:

[untyped]
<PROJECT_ROOT>/node_modules/react-select/*

https://flow.org/en/docs/config/untyped/

Further details at #3804 and #3816

It appears this will be resolved when PR #3626 is merged.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

steida picture steida  ยท  3Comments

pablote picture pablote  ยท  3Comments

jonorogers picture jonorogers  ยท  3Comments

AchinthaReemal picture AchinthaReemal  ยท  3Comments

sampatbadhe picture sampatbadhe  ยท  3Comments