4 ms·
That compiler flag is wonderful, and so is the newer 'strictNullChecks' I use these typings: https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/rea
by boubiyeah 10y ago
That compiler flag is wonderful, and so is the newer 'strictNullChecks'
I use these typings: https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/react/react.d.ts https://github.com/DefinitelyTyped/DefinitelyTyped/blob/mast...
Then create my components like this:
interface Props {
}
interface State {
}
class MyComponent extends React.Component<Props, State> {
}
and everything is typed correctly (beside setState which is impossible to type exactly as of today)
- k__ 10y agoMaybe it was the type definition I used...
- boubiyeah 10y agoStateless component: interface Props { bla: string ble: number } export default function MyComponent({ bla, ble }: Props) { }
- woah 10y agoHow would you do something like this with stateless components? (Where the component is just a function that takes props)
- cwmoo740 10y agointerface IMyComponentProps { x: number; } function MyComponent(props: IMyComponentProps): JSX.Element { return <p>{props.x}</p>; }