prism/examples/prism-tsx.html

32 lines
574 B
HTML

<h2>Full example</h2>
<pre><code>import * as React from 'react';
interface IState {
clicks: number;
}
export class Clicker extends React.Component&lt;any, IState> {
constructor(props) {
super(props);
this.state = {
clicks: 0,
};
}
public clickHandler = () => {
this.setState({ clicks: this.state.clicks + 1 });
}
public render() {
return (
&lt;div>
&lt;p>You have clicked the button {this.state.clicks} time(s).&lt;/p>
&lt;p>
&lt;button onClick={this.clickHandler}>click me&lt;/button>
&lt;/p>
&lt;/div>
);
}
}</code></pre>