Is this the perfect React app? - Code Review

  Рет қаралды 40,870

Cosden Solutions

Cosden Solutions

Күн бұрын

Join The Discord! → discord.cosden...
Repo → github.com/nz-...
Welcome to Code Review!
This is a series of videos where I review code that you send me or that I find online. I review the code as I would when I work with my clients. You will see how a senior developer looks and thinks about code in a variety of scenarios, learn about best practices and how to do things the right way, and learn how to become a better developer overall.
Enjoy!
Darius

Пікірлер: 111
@InfoVerseNetwork
@InfoVerseNetwork Жыл бұрын
It's a fairly big and complex codebase, if he can code this clean and maintainable without typescript, it's even more impressive 🔥
@cosdensolutions
@cosdensolutions Жыл бұрын
Fair point!
@tusharghildiyal6814
@tusharghildiyal6814 Жыл бұрын
Thank you so much the owner of repo and Cosden for this ! Altho i was disappointed to not see typescript being used, but the code is clean and easy to read. got inspired and learned a lot.
@cosdensolutions
@cosdensolutions Жыл бұрын
I feel you with ts, but yes otherwise 10/10!!
@OnlyGoUpW
@OnlyGoUpW 9 ай бұрын
I really found this help full , i hope you make a series of videos reviewing some codes like this , thanks for the information you did make my day ❤
@mounis
@mounis Жыл бұрын
Putting your access token in the local storage makes your site vulnerable to csrf and xss. The best practice will be to use cookies for authentication.
@theSageScriptByGD
@theSageScriptByGD Жыл бұрын
why it passes the userData as props when it could have got that data inside the component itself?
@SurfsUpSeth
@SurfsUpSeth Жыл бұрын
Would it make sense to move the useEffects in app container into seperate hooks that way you can clearly see what each one does and they aren’t all in the app container?
@PranayKotapi
@PranayKotapi Жыл бұрын
tbh, its not that clean or good - relative imports are all over the place - a complex codebase can undergo a lot of refactors - using aliases for paths is always important in such cases
@espresso-byte
@espresso-byte 7 ай бұрын
Absolutely love code review series! 👍
@emmanuelezeagwula7436
@emmanuelezeagwula7436 Жыл бұрын
Damn once I saw this code structure I have a lot to learn
@cosdensolutions
@cosdensolutions Жыл бұрын
you got this 🤙
@Herxh428
@Herxh428 Жыл бұрын
I am working on similar structure everything is so well organized and we are using ts as well.
@flwi
@flwi 5 ай бұрын
Nice! Looks like a great codebase where a lot of thought went into structuring it cleanly. Too bad it's not typescript. ;-)
@kapobajza3708
@kapobajza3708 Жыл бұрын
Honestly this code has a lot of unnecessary boilerplate stuff, which doesn't make it that good. Having a Home, Profile and similar pages which will only render another component is inefficient, because its purpose is to just make you jump one more step or drill down deeper. I mean it would make sense if the same component rendered inside of the Home page is being used elsewhere, but what's the purpose of the Home page if it's only creating a useless abstraction? You should be careful about abstractions, because you can easily get lost in your own code if you have many of them. - There are a lot of useEffect, setLoading(true), setLoading(false) cases. Wouldn't it be easier to extract that to a standalone hook, or better yet use something like RTK query? - Why has the store been put inside of the state of the component? It's unnecessary and it can easily make your code more complex and your app less performant if you're not careful enough. - 2:24 const LIMIT = 10; should also be defined outside of the component
@DavideFicano
@DavideFicano Жыл бұрын
the project doesn't use ESLint at all, for me this is very bad, the "let vs const" situation would be easily found and fixed with the right eslint rules
@cosdensolutions
@cosdensolutions Жыл бұрын
Yeah agreed
@ride.withzero
@ride.withzero Жыл бұрын
I really enjoyed the video! As a junior web developer, I appreciate your advice to learn React despite the negative feedback that some users have given it. I'm a little confused as to why people talk negatively about React, since I'm not very familiar with the "dev culture". It would be great if you could provide some guidance to help clear up any confusion. Thank you!
@cosdensolutions
@cosdensolutions Жыл бұрын
People will always find reasons to hate it. I'm telling you here, React is a solid choice career wise. So I would just focus on learning it and ignore the whole wars they're having. It's what I do! ☺️
@dixztube
@dixztube Жыл бұрын
Here’s what I’d say. React has what you might broadly classify as 3 versions: classes, hooks, and server They are each distinct and you’d not be stretching the truth in suggesting that they almost feel like different libraries. This can cause a lot of push back. This is to say nothing about the debates within each of these versions and between them. Id argue the biggest problem with react is the same as the other libraries and frameworks. They abstract the actual knowledge of how any of these underlying parts work so far away that you could legitimately be employed as a web developer and have no idea how web software and the surrounding architecture and environment work. Go years even without having an idea beyond reacts apis. This to me is it’s biggest problem but that’s more personal. If one chooses ti learn these things by study or doing projects for experience, then react is cool. It’s awesome. But it has a bunch of problems that may or might not be a big deal for your personal journey. I’ve got a medium size project in react and got pretty comfortable and effective with hooks and functional components. I learned during the class era, worked in hooks era, and am now annoyed by server era and might not use react for my next project. A very serious one. But I also don’t feel bad about using react. It’s got a lot of broiler plate and it’s rendering logic and handling of things could always been improved. Maybe it’s even trying to do too much now. I don’t know It’s good for a job. Not great for a great experience. But it’s good for a job and to do a job. But I do find myself disinterested in js on the server vs other languages like go and rust … but I’ll learn the new way of doing things… gripe about it and might use it again if I wanna framework that uses it (like next). I wrote this too after smoking so it might not make proper sense lol
@samking618
@samking618 4 ай бұрын
remember there are only two types of programming languages/frameworks/libraries: The one which everybody hates and the one which nobody use!
@elson_correia
@elson_correia Жыл бұрын
I spotted numerous flaws. Where can I add my CR comments?
@haochen816
@haochen816 Жыл бұрын
Thank you so much for this video and the owner of repo, it helps a lot! Btw, can I know what is the extension you are using that make the top wrapper name/function pinned at the top? Thanks!!
@cosdensolutions
@cosdensolutions Жыл бұрын
It's sticky headers option in vscode, no extension!
@haochen816
@haochen816 Жыл бұрын
I haven’t discovered this setting before. It’s so cool. Thank you~ I'll keep following your channel!! It helps a lot!@@cosdensolutions
@rickyrozario1577
@rickyrozario1577 2 ай бұрын
Only thing missing was TypeScript
@imornar
@imornar Жыл бұрын
To be honest there is so much wrong with this app, cannot believe that dumping server state in redux is still a thing, jeeez...
@cosdensolutions
@cosdensolutions Жыл бұрын
I disagree
@nawazishali274
@nawazishali274 Жыл бұрын
Please make video over protected user role base routing in react js
@jorgericaldi6438
@jorgericaldi6438 8 ай бұрын
why [posts] is a good idea to have as a dependency? it is not a primitive value
@nickolaki
@nickolaki Жыл бұрын
Bad practice to store auth info in localstorage.
@rownokmahbub
@rownokmahbub Жыл бұрын
I don the front end of this website 😁
@thelazycoder64
@thelazycoder64 Жыл бұрын
I'll love to rebuild this using and I'll want you to review it
@jonasj2627
@jonasj2627 Жыл бұрын
Does anyone know a perfect nextjs 13 app like this? I would like to learn from it.
@MohammedShibincp
@MohammedShibincp Жыл бұрын
Is the useSyncExternalStore important in react hooks ?
@cosdensolutions
@cosdensolutions Жыл бұрын
great question! Haven't looked into it too much yet, but I plan to and make a video about it :D
@sebastianmihaiprisacariu8975
@sebastianmihaiprisacariu8975 Жыл бұрын
Great content, but I can not say that not using a framework is react best practices.
@dhruv7827
@dhruv7827 Жыл бұрын
Hey, so I have a question. Which is a better practice : storing authToken in local storage or cookie and why?
@cosdensolutions
@cosdensolutions Жыл бұрын
secure cookie is better, it's harder to manipulate on the client
@dhruv7827
@dhruv7827 Жыл бұрын
@@cosdensolutions Thanks!
@dhruv7827
@dhruv7827 Жыл бұрын
@@cosdensolutions Are there any better alternatives that you yourself use?
@madsfrost9464
@madsfrost9464 Жыл бұрын
Where is the TypeScript?
@cosdensolutions
@cosdensolutions Жыл бұрын
it's there, it's just invisible 😅
@SingajogiSudhakar
@SingajogiSudhakar Жыл бұрын
Hey Bro, i'm building one application in reactjs, how i can reach you for reviewing that app
@cosdensolutions
@cosdensolutions Жыл бұрын
discord! link in the description
@emiralabuga9451
@emiralabuga9451 Жыл бұрын
Hey, what is your vscode theme?
@cosdensolutions
@cosdensolutions Жыл бұрын
Material theme darker
@sd4545sdf
@sd4545sdf 6 ай бұрын
perfect app with a few thousands lines of redux lol
@swaniketchowdhury
@swaniketchowdhury Жыл бұрын
How do I submit a app for review?
@cosdensolutions
@cosdensolutions Жыл бұрын
on the discord there's a channel for it!
@nawazishali274
@nawazishali274 Жыл бұрын
Nice🎉
@iamilyes
@iamilyes Жыл бұрын
why is he storing the auth token in local storage !! is this safe/okay ?
@cosdensolutions
@cosdensolutions Жыл бұрын
It's not the best but it is what it is, I've seen plenty of apps do that
@jazzdestructor
@jazzdestructor Жыл бұрын
well you can store it in redux but after refresh its gone, most ecommerce apps use jwt and store it in local. unless the secret key is somehow hacked it is not a big issue, but might need to make sure that somebody doesn't take the token and ping server using postman etc. that can be handled by devops or backend by allowing only specific endpoints to send requests.
@icoderdev
@icoderdev Жыл бұрын
❤👌
@AhmadMughal1
@AhmadMughal1 Жыл бұрын
As far as i can think this was a project which was done by a youtuber and the only changes i see so far is the branding of the product so i wouldn't actually credit the user for writing this code as it is mostly just copied over from the video.
@cosdensolutions
@cosdensolutions Жыл бұрын
hmm?
@AhmadMughal1
@AhmadMughal1 Жыл бұрын
@@cosdensolutions oddly similar to this kzbin.info/www/bejne/gWm8dn-IorqVa9Esi=nXxlfku3PQ1JgKJx
@nzm_1
@nzm_1 Жыл бұрын
Looking at the source code, it doesn't seem like it was copied from an 8-9 hour tutorial video. It took much more time than that.
@AhmadMughal1
@AhmadMughal1 Жыл бұрын
@@nzm_1 the UI was just eerily similar and the structure was a bit too might have been a mistake on my end.
@jwbonnett
@jwbonnett Жыл бұрын
There is no such thing as perfect, there is no silver bullet.
@joseeavr
@joseeavr 3 ай бұрын
to be honest, i dont think this react app is perfect. it noticed many anti-patterns
@beachneosculpordwarf
@beachneosculpordwarf Жыл бұрын
This is like 2018 - 2019 grade react 💩... U literally will be fired if u write this in 2023
@ND-bn
@ND-bn Жыл бұрын
So, people used to write 💩 code in 2018/19? 🤔
@beachneosculpordwarf
@beachneosculpordwarf Жыл бұрын
@@ND-bn 1. If you write like 2018 - 2019 grade react, then it is considered 💩 in 2023 2. 💩 code was written in 2018/19 3. Therefore, all code from 2018 - 2019 is 💩 This is a fallacy because there could be other reasons for code to be considered 💩 in 2023 that are not related to the practices of 2018 - 2019. Just because some code from that period is considered subpar in 2023 doesn't mean all code from that period is subpar You better of typing the following commands: npm install -g @angular/cli ng new my-app Than writing a redux without typescript based app - with custom handling of server state Side Note: I don't watch this channel, but assume this is beginner focused content, thus this is a bad advice -> I can give u 3 better real production open source React repos on top of my head if u really want to learn some production grade code. 1. "Make Ur Own Framework" - github.com/Ajaxy/telegram-tt 2. "Subdue draggables" - github.com/excalidraw/excalidraw 3. "Classic Chat Case" github.com/RocketChat/Rocket.Chat 4. And many more.. My examples are complex, but for a right reason - figure why this one is bad
@cosdensolutions
@cosdensolutions Жыл бұрын
I disagree
@zackaryleitzel9118
@zackaryleitzel9118 Жыл бұрын
i agree with this
@andreicatalin7
@andreicatalin7 Жыл бұрын
And why is that? Give some reasons...😞
@onta.nicolae
@onta.nicolae Жыл бұрын
what vscode theme is this?
@cosdensolutions
@cosdensolutions Жыл бұрын
material theme darker
@onta.nicolae
@onta.nicolae Жыл бұрын
@@cosdensolutions thank you
@cosdensolutions
@cosdensolutions 6 ай бұрын
Hey everyone! I just launched 🚀 Project React, which is a course that teaches you React by building a real-world project. It goes way beyond what you see in these videos and walks you through step-by-step on how to build a big and complex application with React! You can check it out here: cosden.solutions/project-react
@webcodeuniversity
@webcodeuniversity Жыл бұрын
I think putting store creation inside an effect doesn't make any sense, there's no need for that, just create the store outside of that component (import it or above the file), then inject it into the provider, apart from that it seems a good one
@Vagabondi404
@Vagabondi404 Жыл бұрын
lost 20 iq watching the thumbnail
@cosdensolutions
@cosdensolutions Жыл бұрын
😅
@cbijay
@cbijay Жыл бұрын
There is no test case. Also we can use absolute path for import which is missing in the codebase
@isaacjon
@isaacjon Жыл бұрын
how can i achieve this kind of clean code and architecture compared to my current shit code ? how do i imporove myself
@cosdensolutions
@cosdensolutions Жыл бұрын
Time and practice! Use this code to learn from and try to implement piece by piece
@yajraarserotsejay1674
@yajraarserotsejay1674 Жыл бұрын
Im inspired to create my own small social media app too. Im a mid level fullstack developer who wants to be senior soon
@cosdensolutions
@cosdensolutions Жыл бұрын
do it! social media app is exactly what brought me from mid to senior
@alexandernortung9365
@alexandernortung9365 Жыл бұрын
Honestly the code was fine, I feel like you hyped it up a bit too much and it wasn't even in typescript. at 6:52 you say that we should use useMemo otherwise it will invalidate the memo, and that is not correct. useMemo will make sure you are using the same reference to the array in this case.
@cosdensolutions
@cosdensolutions Жыл бұрын
might be fine to you and me, but compared to the code I see daily, this is the gold standard. The only thing missing here is typescript, otherwise it's a 10/10 so yes I will hype it up
@joemignano
@joemignano Жыл бұрын
The wording here caught my attention, too, as I first kind of heard "you need to use useMemo() with memo() in order for memo() to work (generally)," but it sounds like Darius is right here that the of the memo() on the PostToProfile component is "invalidated" in this situation because the `posts` array is reset and hence mapped through again in each re-render (...I'm pretty sure?). @cosdensolutions, In a different situation, if the MemoizedPostOnProfile component was still wrapped in a memo() but, instead of being mapped through directly in the UserProfile component, it was, say, mapped through in a separate PostToShow component which had the posts as a prop and itself was memoized with memo(), wouldn't that have the same effect without using useMemo() at all?
@Nonamedsejennsyueehzv
@Nonamedsejennsyueehzv 10 ай бұрын
Watch video + comments as well both are helpful - this comment is advice for me for future reference
@abhishekcode
@abhishekcode Жыл бұрын
Sir please make a video of MERN full stack app of e-commerce site❤..From basic to advance
@seekheart2023
@seekheart2023 10 ай бұрын
I am not a fan of export default
@joseeavr
@joseeavr 3 ай бұрын
for components, i won't but for ts files, it is fine.
@viophile
@viophile Жыл бұрын
TypeScript not used, not good.
@cosdensolutions
@cosdensolutions Жыл бұрын
agreed! but all things considered, it's still a great app
@tusharghildiyal6814
@tusharghildiyal6814 Жыл бұрын
i was about to say the same. no real world is app is made without typescript these days. but i liked the code though. its clean and concise. Learned a lot !
@avivshvitzky2459
@avivshvitzky2459 Жыл бұрын
I worked in 4 starups, none uses typescript. 1 is a unicorn@@tusharghildiyal6814
@vishwasrv
@vishwasrv Жыл бұрын
All the idiots here knitpicking on the code, for what its worth , its pretty good and understandable 😁, its good enough code thats worth to ship 🚢
@cosdensolutions
@cosdensolutions Жыл бұрын
people nitpick on everything, which really shows insecurities on their side. this code is top quality
@vishwasrv
@vishwasrv Жыл бұрын
@@cosdensolutions I totally agree 😇
@onta.nicolae
@onta.nicolae Жыл бұрын
can you do a video on your vscode config? 🙏
Too many useEffects! - Code Review
14:05
Cosden Solutions
Рет қаралды 13 М.
This is way too complicated! - Code Review
19:31
Cosden Solutions
Рет қаралды 22 М.
My daughter is creative when it comes to eating food #funny #comedy #cute #baby#smart girl
00:17
React Like a Pro: React Best Practices
9:55
PedroTech
Рет қаралды 12 М.
From Junior To Senior React Developer - Best Practices
13:33
CoderOne
Рет қаралды 148 М.
The correct way to optimise React
11:29
Cosden Solutions
Рет қаралды 33 М.
Why Did They Do This?! (Code Review)
18:48
Cosden Solutions
Рет қаралды 15 М.
Stop Doing this as a React Developer
12:27
CoderOne
Рет қаралды 163 М.
Turning bad React code into senior React code
13:10
Cosden Solutions
Рет қаралды 90 М.
React Query Is (Still) Essential - My Favorite React Library
11:04
Theo - t3․gg
Рет қаралды 152 М.
Why Signals Are Better Than React Hooks
16:30
Web Dev Simplified
Рет қаралды 478 М.
You might not need useEffect() ...
21:45
Academind
Рет қаралды 161 М.