Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

JavaScript

Malachi Gruenhagen
Malachi Gruenhagen
1,857 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?