Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript

Malachi Gruenhagen
Malachi Gruenhagen
3,226 Points

"React.Props<T> is now deprecated" warning in IDE when attempting to destructure props in AddPlayerForm

So I changed the AddPlayerForm class to destructure props (as suggested by the video). This only required changing the handleSubmit() method:

    handleSubmit = (e) => {
        const { addPlayer } = this.props;
        e.preventDefault();
        addPlayer(this.state.value);
        this.setState({ value: '' })
    }

My IDE (WebStorm) then gave me the following warning:

React.Component<P,S>.props: Readonly<P> & Readonly<{children?: ReactNode}>

React.Props<T> is now deprecated, which means that the children property is not available on P by default, even though you can always pass children as variadic arguments to createElement. In the future, if we can define its call signature conditionally on the existence of children in P, then we should remove this.

  react.d.ts

Did I do anything wrong? Was there a better way to do this?