vscode-glean: Unable to convert setState(function) to hooks

I’m unable to convert to class to functions when I use setState with a function argument. For example:

this.setState(prevState => ({
      profile: {
        ...prevState.profile,
        roles: [
          ...prevState.profile.roles,
          {
            title: "",
            link: "",
          }
        ]
      }
    }));
  };

The expected output should be:

setProfile({ ...profile, roles:[...profile.roles, {title: "", link: "" }]})

But instead I get an error: "“Cannot read property ‘forEach’ of undefined”.

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 17 (17 by maintainers)

Most upvoted comments

@aeciorc Thats actually a bug. I’ve noticed it too and already have a fix for it in a branch im working on