Design comparison
SolutionDesign
Solution retrospective
Hi frontend mentor community!
I had a difficult to make a condition rendering (in box.js in box component). If you have any ideas how I can make it more elegante, do not hesitate.
Anna
Community feedback
- @fazzaamiarsoPosted over 2 years ago
Hello Amichno! Great work!
You can do it with ternary operator. Here is my implementation.
return ( <Back> <Wrapper> { voted !== 'voted' ? ( <> <Logo/> <Card inv ={invitation}/> <Score scores={scores} onClick={onClickRate} rate={rate}/> <ButtonSubmit voted={voted} onClick={onClickVote}/> </Wrapper> : <Succes rate ={rate}/> )} </Wrapper> </Back> )
When using ternary operator, your code can be a mess (coming from experience😥). So, I recommend you to setup prettier. https://prettier.io/
I hope it helps! Cheers!
Marked as helpful0@amichnoPosted over 2 years ago@fazzaamiarso
Thank you Fazza Razaq Amiarso, now it looks much better.
0
Please log in to post a comment
Log in with GitHubJoin 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