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.

Properties becomes undefined and then not

See original GitHub issue

Bug Report

  • I would like to work on a fix!

Current behavior

Using path.node.declarations[0].init.arguments[0].properties where path.node is a VariableDeclaration always causes an error claiming that is undefined but when I use console.log to print it, it prints it’s value (not undefined), and then creates an error saying that it is undefined when it isn’t. Some of my code uses ES6 filter in two instances. When I create a third instance, having my code print path.node.declarations[0].init.arguments[0].properties == undefined has it print true and then false and then creates an error that it is undefined when using filter on it.

Expected behavior A clear and concise description of what you expected to happen (or code).

Babel Configuration (babel.config.js, .babelrc, package.json#babel, cli command, .eslintrc)

  • Filename: babel.config.js
{
  "your": { "config": "here" }
}

Environment


  • Babel version(s): [v6.26.3]
  • Node/npm version: [Node 12.16.1/6.14.17]
  • OS: [Windows 10 10.0.18363]
  • Monorepo: [no]

Additional context This appears when I am writing a plugin using the visitor pattern.

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
shadowtime2000commented, Oct 1, 2020

@shadowtime2000 Can you share a reproduction repo?

@JLHwung shadowtime2000/react-class-functional on branch experimental

0reactions
shadowtime2000commented, Nov 10, 2020

@JLHwung

import React from "react";

const Hey = React.createClass({
  componentDidMount() {
    console.log("a");
    console.log("b");
  },

  componentWillUnmount() {
    console.log("Hey component unmounted");
  },

  render() {
    return <div>Hey!</div>;
  }
});

export default Hey;
Read more comments on GitHub >

github_iconTop Results From Across the Web

Object property become undefined after call setState
Your state has multiple properties. If you start out with properties messageInfo and type , for example, and then you do this.
Read more >
undefined - JavaScript - MDN Web Docs - Mozilla
undefined is a property of the global object. That is, it is a variable in global scope. In all non-legacy browsers, undefined is...
Read more >
7 Tips to Handle undefined in JavaScript
The short answer is that JavaScript interpreter returns undefined when accessing a variable or object property that is not yet initialized.
Read more >
How to Prevent the Error: Cannot Read Property '0' of ...
A guide on how to prevent the error "cannot Read Property '0' of Undefined", covering techniques such as try, catch, using const over...
Read more >
Why are my objects are undefined?
What you will see is that they will name the property after its property-key. Then describing your object1 would sound like: “Object1 has...
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