question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue

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

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
gaearoncommented, Sep 30, 2018

Yeah, I understand. We’ll need to dig deeper into this.

0reactions
Gpxcommented, Sep 30, 2018

@bugzpodder yep, that works, unfortunately, in my app, we use prettier which converts comments into standard type definitions. I think we’ll wait to update CRA until this issue has been closed

Read more comments on GitHub >

github_iconTop Results From Across the Web

TypeError: Cannot read property 'bind' of undefined, I can not ...
javascript - TypeError: Cannot read property 'bind' of undefined, I can not figure what this means. React js - Stack Overflow. Stack Overflow ......
Read more >
What is "TypeError: Cannot read property 'state' of undefined"?
The error message says that you don't have the state property on an undefined object. To decode this, we have to understand the...
Read more >
TypeError: Cannot read property 'bind' of undefined - Odoo
Traceback: TypeError: Cannot read property 'bind' of undefined at http://localhost:8069/web_editor/static/src/js/wysiwyg/root.js:46:57 at Function._.each._.
Read more >
Data binding - Polymer Project
A data binding connects data from a custom element (the host element) to a property or attribute of an element in its local...
Read more >
How to bind 'this' keyword to resolve classical error message ...
Basically this keyword inside a function is determined by looking at how the method is actually invoked. Usually in JavaScript, we invoked the ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found