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 Applications with React and Redux Modularizing the React Scoreboard Application Cleaning up the Scoreboard Container Component

I'm confused by some of the syntax changes that were made when modularizing, specifically in Scoreboard.js

After modularizing the app, the key value properties of the scoreboard component were changed to just regular declarations of variables and functions. So in this methodology the scoreboard component is no longer an object? like onScoreChange went from being onScoreChange: to onScoreChange = (index, delta) =>.

I understand ES6. But does it always have to be like this when modularizing? Can you keep it as an object if export is called separately at the bottom?

1 Answer

You don't have to. For example you don't have to use :

export default class Scoreboard extends Component 

You can use the React.createClass syntax.

It's just that the class syntax may look better visibility, and it works. However, I think React.createClass is deprecated in newer versions of React, so the class syntax is a better option.