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 Introducing the Practice

importing React and exporting components

Why in this exercise we don't need ( and can't ) to import React and if I try to export components it returns an error: "Uncaught ReferenceError: exports is not defined"

I noticed of course in this exercise all our script is based on only one page. And maybe it is unnecessary to export components. But why is it an error?

1 Answer

Ignacio Rocha
Ignacio Rocha
7,462 Points

Hi kuarzan! First of all yes the exercise is meant to be solved with just one file, no exports nor imports because you aren't using more files or components, also remember that the index.html file has the package of React and ReactDOM because is not using Node.

To the question why is throwing an error it's because require is not a client side function so you need to use a Module Loader or Module Bundler to help you with the dependency management. Is this exercise it's not required to use them tho.