@
@
@Richswitch2018-11-09 10:28:09
JavaScript
@Richswitch, 2018-11-09 10:28:09

Bug in TypeScript, how to fix?

Hey!
How to fix a bug

Type '{}' is not assignable to type 'Readonly<Props>'.
  Property 'props' is missing in type '{}'
?
The code is like this:
interface Props {
  props: Object;
}

class App extends React.Component<Props> {
  constructor(props: Props) {
    super(props);

  }
  public render() {
    return (
      <AppWrap>
        <Block>Block</Block>
      </AppWrap>
    );
  }
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Demian Smith, 2018-11-09
@search

Remove this part

constructor(props: Props) {
    super(props);
  }

This code is executed automatically in the React.Component class. It doesn't need to be duplicated.
UPD
In general, the code is slightly strange. I understand that App is your main component. I assume that it is drawn in the index.ts file. Does your App really need props? If needed, they must be transferred. Something like that:
<App props={} />

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question