Quiz

This quiz will test what you have learned about strongly-typing class components.

Creating strongly-typed class components

1

We have a CountDown component that has no props but has a count state. How can we declare the CountDown component with strongly-typed count state and initialize it to 10?

A)
type State = {
  count: number;
};
class CountDown extends React.Component<State> {
  constructor(props: {}) {
    super(props);
    this.state = {
      count: 10
    };
  }
  ...
}
B)
type State = {
  count: number;
};
class CountDown extends React.Component<{}, State> {
  constructor() {
    this.state = {
      count: 10
    };
  }
  ...
}
C)
class CountDown extends React.Component<{}, {count: number}> {
  constructor(props: {}) {
    super(props);
    this.state = {
      count: 10
    };
  }
  ...
}
Question 1 of 50 attempted

Get hands-on with 1200+ tech skills courses.