Space Tourism Site w/ React , React router

Solution retrospective
Hello, this is my first time using react router on a project. I am proud of the final product but I am always happy for constructive criticism :)
Please log in to post a comment
Log in with GitHubCommunity feedback
- @fazzaamiarso
Hi Yosef, Well done!
I have some quick improvements for you:
- You can use Template String for dynamic class, rather than conditional rendering. Ex:
// instead of index === 0 ? <button onClick={() => {setIndex(0);}} className="tech-btn activated">1</button> : <button onClick={() => {setIndex(0);}} className="tech-btn">1</button> // ✅ you can do this <button onClick={() => {setIndex(0);}} className=`tech-btn ${index === 0 ? "activated" : ""}`>1</button>
- As react re-renders every state changes, you can index an item on render. Ex:
// instead of let techName = []; let info = []; let i = 0; for(let tech of Data.technology){ techName[i] = tech.name; info[i] = tech.description; i++; } // ✅ do this const currentTechnology = Data.technology[index]; // index on render const techName = currentTechnology.name const techInfo = currentTechnology.description return { <h2 className="tech-name">{techName}</h2> <p className="tech-description">{techInfo}</p> }
Hope it help! Cheers!
Marked as helpful
Join our Discord community
Join thousands of Frontend Mentor community members taking the challenges, sharing resources, helping each other, and chatting about all things front-end!
Join our Discord