React and Typescript: Convention for classes when props are not passed

I am wondering what the correct way is to indicate that the React component does not have props in Typescript.

If I have a component, I can indicate which details and status have two interfaces:

interface MyProps {
  text: string
}

interface MyState {
  count: number
}

class MyComponent extends React.Component<MyProps, MyState> {
  ...
}

So, if my component does not have props, should I use void, undefinedor {}?

+4
source share
1 answer

This exact (almost) question is answered in the Typescript 2.3 declaration .

. {}, :

class FooComponent extends React.Component<FooProps, object> {
    // ...
}

, object props .

+1

Source: https://habr.com/ru/post/1676603/


All Articles