Typescript equivalent for react this.setState({[item]:data});

Viewed 32

I'm updating a react application I wrote to use typescript and I have been using

this.setState({ [item]: data }); 

to populate the state from a fetch call. Typescript doesn't like this and in the interest of expediency I'd like to find a hacky way to make this work by ignoring types. The data returned from this fetch call is always a string.

0 Answers
Related