Skip to content

Cannot read property 'type' of null error in no-array-index-key.js #1242

Closed
@alaycock

Description

Version 7.0.1
The full stack trace can be found below.

screen shot 2017-06-06 at 1 20 23 pm

The issue occurs when I begin to add the key to this code:

      this.state.array.map((arrayItem, index) => (
        <div>
          <button onClick={() => this.delete(index)}>Delete this thing</button>
        </div>
      ))

If I begin to enter the key attribute:

      this.state.array.map((arrayItem, index) => (
        <div key>
          <button onClick={() => this.delete(index)}>Delete this thing</button>
        </div>
      ))

An error in the console is triggered, although I wasn't finished writing the new line.

The issue appears to be on this line, and I suspect it could be corrected altering the line to be if (!value || value.type !== 'JSXExpressionContainer') {, but I'm not sure about the implication of making that change.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions