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 trialJohn Y
4,759 PointsCan't add route to Home component
After adding <Route path="/" component={Home} />, I get the following error:
Failed to compile.
./src/components/App.js Line 10: 'Home' is not defined no-undef
Search for the keywords to learn more about each error.
The instructions on how to go from create-react-app to merging in the example files were pretty unclear β perhaps I have done something wrong there? Could somebody tell me the exact steps for setting up the sample app?
And if anybody knows how to make npm start NOT open a browser tab (inevitably in the wrong window of the wrong browser) even though I already have one open, that's be great too :)
1 Answer
John Y
4,759 PointsDuh. Apparently I should have carried on watching the video to find out what the error was about!
The perils of doing these courses late in the evening, I guessβ¦
As for the auto-opening browser tab, changing "start": "react-scripts start",
to "start": "BROWSER=none react-scripts start",
in package.json will fix it.
Gabbie Metheny
33,778 PointsGabbie Metheny
33,778 PointsThanks for researching how to stop the app from loading a new tab, that had been driving me crazy!
The above code didn't quite work for me, but this did (per create-react-app's github repo):
Either run
BROWSER=none npm start
(which gets old fast), or create a.env
file at the root of your project directory, and add the lineBROWSER=none
to it. I believe you can also set your browser of choice here, which is useful if you use a browser other than your OS's default browser for development.