Skip to content

[0.55] regression - react synthetic events (try flow bug only?) #4966

@rosskevin

Description

@rosskevin

SyntheticEvents appear to not be included in 55, but works in 54.1 and lower

Test code (linked above):

import * as React from 'react';

type Props = {
  onChange?: (value: ?string) => void
};

class MyComponent extends React.Component<Props> {
  handleClick = (e: SyntheticEvent<>) => {
	const {onChange} = this.props
    if (onChange) {
      onChange('foo clicked')
    }
  }
  
  render() {
    return <div onClick={this.handleClick}>foo</div>;
  }
}

<MyComponent />;
8:   handleClick = (e: SyntheticEvent<>) => {
                       ^ identifier `SyntheticEvent`. Could not resolve name

This seems like a regression, because these SyntheticEvents are still in the libdef https://github.com/facebook/flow/blob/v0.55.0/lib/react-dom.js

and recommended to be used by https://flow.org/en/docs/react/events/

Here is an exact 55 try flow of the docs example, which also works in 54.1 and lower.

I actually came to report a different issue and when trying to boil down the test case, perhaps this is the root cause.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions