scrimba
21 web dev tips for 2021 🎇
Tip 2: Clean Code Part 2
Go Pro!Bootcamp

Bootcamp

Study group

Collaborate with peers in your dedicated #study-group channel.

Code reviews

Submit projects for review using the /review command in your #code-reviews channel

AboutCommentsNotes
Tip 2: Clean Code Part 2
Expand for more info
components
App.js
run
preview
console
// Clean Code Examples Part Two - React

// 1. If you are going to use semicolons - use semicolons
import React from 'react';
import ReactDOM from 'react-dom'

// 2. Make sure your JSX is formatted correctly, then names are formatted correctly, and use 'className' instead of 'class'
const Section = () => {
return (
<div>
<div class="primarysection"></div>
</div>
)
}



// 3. Boolean variables, or functions that return a boolean value, should start with 'is', 'has' or 'should'. (Also applicable to other languages)
let gameOver = true

// 4. Destructure your props

const Wrapper = (props) => (
console.log(props.children)
)

// 5. Mini Challenge: Please fix the code snippet below
import React from 'react'
import ReactDOM from 'react-dom'

const App = () => {
return (
<div>
<div className="firstdash"></div>
<div className="seconddash"></div>
<div className="container">
<div className="dot"></div>
<div className="thirddash"></div>
</div>
</div>
)
}

export default App
Console
›
Error: SyntaxError: unknown: Identifier 'React' has already been declared (32:7) 30 | 31 | // 5. Mini Challenge: Please fix the code snippet below > 32 | import React from 'react'; | ^ 33 | import ReactDOM from 'react-dom'; 34 | 35 | const App = () => { (/components/App.js:32)
,
/index.html
-6:46