React integration

React integration

To use JSX with React you should use the React typings. These typings define the JSX namespace appropriately for use with React.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
/// <reference path="react.d.ts" />
 
interface Props {
  foo: string;
}
 
class MyComponent extends React.Component<Props, {}> {
  render() {
  return <span>{this.props.foo}</span>
  }
}
 
<MyComponent foo="bar" />; // ok
<MyComponent foo={0} />; // error
doc_TypeScript
2025-01-10 15:47:30
Comments
Leave a Comment

Please login to continue.