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

Roderick Morales
477 Pointsusing JS to do component composition
The instructor challenged us to create a component for the counter. I was able to do that and included it into Player component like this:
{ Counter() };
I basically applied the concept that anything inside the brackets is JS, so I was just calling a function inside another function.
Is this ok or not? should I just stick to self-closing tags?
1 Answer

Milan Toth
12,182 PointsYou can add any JS expressions inside the curly braces in React, so yes, you can call a function or make calculations etc. Would need to see your code to see if there is a better way of doing what you are doing.