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 trialMarius Adam
1,736 PointsonClick 1 and -1 to 0.5 and -0.5 otherwise increment by 2???
In the Counter I had to change the 1 and -1 to 0.5 and -0.5 because otherwise on click the score would increment by 2. Any ideas why this happened?
4 Answers
Oliver Duran
Full Stack JavaScript Techdegree Graduate 22,828 PointsHey Marius! i fixed that problem by removin this from the index.js file, i do not know why but it worked!
ReactDOM.render(
<React.StrictMode>
<App />
</React.StrictMode>,
document.getElementById('root')
);
ReactDOM.render(
<App />,
document.getElementById('root')
);
John Lamontagne
3,201 PointsThanks for this, it seems like some weird code that Treehouse has put in.
Jan Xavier Virgen
Full Stack JavaScript Techdegree Graduate 19,751 PointsThank you!
Vivian Rydh
8,873 PointsThank you. ^_^
Brian Beal
5,544 PointsIt's an intentional feature of the StrictMode. This only happens in development, and helps find accidental side effects put into the render phase. We only do this for components with Hooks because those are more likely to accidentally have side effects in the wrong place.
Terence Wayburne
Full Stack JavaScript Techdegree Graduate 31,428 PointsThanks, I was wondering for a while and coudlnt figure it out...
Emil Lau
6,233 PointsThanks for the answer, but I still don't get why disabling strict mode could solve this.
Oliver Duran
Full Stack JavaScript Techdegree Graduate 22,828 PointsOliver Duran
Full Stack JavaScript Techdegree Graduate 22,828 PointsSame issue here.