0

I am having the same exact issue as what is detailed here:

https://github.com/Microsoft/TypeScript/issues/13948

Is there a resolution to this? I was thinking that maybe it is a typescript version error, but I am still having the same problem with version 2.0.

2
  • The latest version is 2.4 Commented Aug 5, 2017 at 4:47
  • updated to latest but still getting the error... Commented Aug 5, 2017 at 4:55

1 Answer 1

1

You can use alternate option, like you can create new obj variable like this:

handleUpdate (e:React.SyntheticEvent<HTMLInputElement>) {
    const key = e.currentTarget.name as keyof Person;
    const value = e.currentTarget.value;

    //New Code
    let obj ={}
    obj[key] = value
    this.setState(obj, ()=>{ alert(JSON.stringify(this.state)) })
  }

Its working find check this CodeSandbox Snippet

Sign up to request clarification or add additional context in comments.

1 Comment

thanks! that worked. why does it happen? I'm guessing there must be a fix that does not involve a workaround?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.