1. Missing Export Statement
Mistake:
File: src/App.js
File: src/components/Counter/index.js
2. Missing Import Statement
Mistake:
File: src/App.js
File: src/components/Counter/index.js
3. Missing Extending the React Component Class
Mistake:
File: src/App.js
File: src/components/Counter/index.js
4. class vs className
Mistake:
File: src/components/Counter/index.js
5. onclick vs onClick
Mistake:
File: src/components/Counter/index.js
6. Event Listeners inside Class Component
Mistake:
File: src/components/Counter/index.js
Solution:
In Arrow functions,
7. Passing Event Handler
Mistake:
File: src/components/Counter/index.js
Solution:
8. Modifying the State Directly
Modifying the state directly won't trigger the
Mistake:
Solution:
Updating Object
Mistake:
Solution:
Updating List
Mistake:
Solution:
9. Calling setState() from render()
Mistake:
Specifying a new state with
When we call setState from the
10. Invoking Event Handler
Mistake:
Soution:
11. setState() is Asynchronous
Mistake:
12. React Component should return a single JSX element
Mistake:
12.1 Fragments
The fragment is an alternate way to return a single JSX element. It groups a list of children without adding extra nodes to the DOM.
Short Syntax:
13. Props are Read-only
Mistake:
File: src/App.js
File: src/components/Welcome/index.js