Skip to content

Instantly share code, notes, and snippets.

@mredem96
Created February 11, 2019 17:00
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 mredem96/ca2afaffd695d270db3314db1804c03e to your computer and use it in GitHub Desktop.
Save mredem96/ca2afaffd695d270db3314db1804c03e to your computer and use it in GitHub Desktop.
Statefull components
import * as React from 'react';
interface IStateComponent{
time:Date();
}
interface IPropComponent{
name:string;
}
export class TypedComponent extends React.Component<IPropComponent,IStateComponent>{
constructor(props : IMyComponentProps) {
super(props);
this.state = { time: new Date(); };
}
public render() {
return (
<div>
My name is {this.props.name}
</div>
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment