Skip to content

Instantly share code, notes, and snippets.

@srkirkland
Created November 29, 2017 22:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save srkirkland/b4e7e8f3b3037398d5680b1f4dba6b6a to your computer and use it in GitHub Desktop.
Save srkirkland/b4e7e8f3b3037398d5680b1f4dba6b6a to your computer and use it in GitHub Desktop.
failing typescript stuff
Warning: setState(...): Can only update a mounted or mounting component. This usually means you called setState() on an unmounted component. This is a no-op.
Please check the code for the HelloWorld component.
import * as React from "react";
// Provider
export default class HelloWorld extends React.Component<{}, any> {
constructor(props: any) {
super(props);
this.state = { name: "" };
}
handleChange(event: any): void {
this.setState({ name: "Charles" });
}
render() {
return (
<div>
Hello {this.state.name}!
<button name="Update" onClick={e => this.handleChange(e)}>
Update
</button>
</div>
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment