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 Building a Search Feature

super(),props

HI, Why is there no super() in Searchform.js? and where is props passed as a parameter on line 15 in the same file.

Kind Regards

Henry Blandon
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Henry Blandon
Full Stack JavaScript Techdegree Graduate 21,521 Points

Azzie Fuzzie, the SearchForm does not have a constructor; therefore, the super() method is not required. Also in the SearchForm he is using a short cut to initialized the state which is not supported in all browsers, but because He is not using super() method, he does not use "this" to initialize the state. Here is the link of the video where He talks about it. (https://teamtreehouse.com/library/create-a-stateful-component) I would still use the constructor to avoid any issues with browser compatibility.

The props is passed in the app class in the render method under the return statement, look for the ** <SearchForm onSearch={this.performSearch} />**

1 Answer

Reggie Williams
STAFF
Reggie Williams
Treehouse Teacher

Hey Azzie Fuzzie super is in the final project files on line 10 and you can learn more about super here and the props parameter is coming from the app.js file where performSearch is passed into the searchForm component