Skip to content

TypeError: Cannot read property 'bind' of undefined when using Flow #5176

Closed
@Gpx

Description

@Gpx

Is this a bug report?

Yes

Did you try recovering your dependencies?

Yes

Which terms did you search for in User Guide?

flow bind

Environment

Environment:
  OS:  macOS Sierra 10.12.6
  Node:  10.11.0
  Yarn:  Not Found
  npm:  6.4.1
  Watchman:  4.7.0
  Xcode:  Xcode 9.2 Build version 9C40b
  Android Studio:  Not Found

Packages: (wanted => installed)
  react: ^16.5.2 => 16.5.2
  react-dom: ^16.5.2 => 16.5.2
  react-scripts: 2.0.1 => 2.0.1

Steps to Reproduce

  1. Create a component like this one
  class Foo extends React.Component {
    constructor(props) {
      super(props)
      this.foo = this.foo.bind(this)
    }
    foo: () => ()
    foo() {}
    render() { return <div /> }
  }
  1. Run the tests for Foo
  2. TypeError: Cannot read property 'bind' of undefined

Expected Behavior

The file should run in the tests

Actual Behavior

I think Flow's syntax is confusing the tests. Note that this same code was working in the previous version of CRA

Reproducible Demo

Simply clone https://github.com/Gpx/cra2-bind and run the tests

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions