Тёмный

4 React Best Practices That Will Make You A PRO 

PedroTech
Подписаться 204 тыс.
Просмотров 144 тыс.
50% 1

In this video I will be talking about my opinions on React Best Practices.
Join our Discord: / discord
🚀 Learn ReactJS By Building 6 Projects: codedamn.com/learn/reactjs-pr...
🐙 GraphQL Course: codedamn.com/learn/graphql-fo...
► Buy Crypto on Coinbase: coinbase-consumer.sjv.io/PedroTech
Social
▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬
Website: machadopedro.com
Linkedin: / machadop1407
Instagram: / _pedro.machado_
Github: github.com/machadop1407
Business Email: pedro@pedrotech.co
Tags:
- ReactJS Tutorial
- ReactJS and MySQL
- NodeJS Tutorial
- API Tutorial
TIMESTAMPS
00:47 - Dividing your project into components
06:15 - Using Fragments
09:05 - Relationship between States and Objects
13:13 - Typechecking
#reactjs #coding

Наука

Опубликовано:

 

25 июн 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 158   
@Pointcut
@Pointcut 2 года назад
Personal Timestamps 03:21 - Separating your functionality into components will prevent unnecessary re-renders. 07:43 - Use empty (or ..) fragment tags to add multiple elements to a React Component without wrapping it in an extra DOM node (such as a ) 10:39 - Sometimes it's best to separate your useState hook data into multiple hooks, instead of using a single hook with an object. 14:50 - Typechecking your props is important
@hoaxygen
@hoaxygen Год назад
Thanks for saving me 20 unnecessary min!
@TagFul19
@TagFul19 Год назад
@@hoaxygen lol
@succeedwithuttam2271
@succeedwithuttam2271 11 месяцев назад
Typechecking by using proptypes. simply amazing.
@ThColinPereira
@ThColinPereira 2 года назад
whoa, the effects in this video were really cool! great video, pedro!
@superurgmail
@superurgmail 2 года назад
How about a video on debugging in React? There doesn't seem to be many good videos on debugging React. It could be super useful. :)
@PedroTechnologies
@PedroTechnologies 2 года назад
Great suggestion!
@badcode8029
@badcode8029 2 года назад
yes thats all i want to see a various way to debugging react from every developer
@baotruong5775
@baotruong5775 Год назад
Everything's clear!!! Your voice, your lessons!!! Thank you so much
@PPMBlast
@PPMBlast Год назад
React Dom and life cycle are super important and I feel go unmentioned in most tutorials. Really glad to see that someone mentioned components containing all nessesary logic stops unnecessary rerendering
@shafanm
@shafanm 2 года назад
Hey Pedro, great video as always. Really appreciate all the hard work you put in and the time you are investing in this channel. I wanted to add my insight on the "Relationship between States and Objects" subject that you mentioned. There is another important consideration that one needs to be aware of when deciding to use a single Object state or split it into multiple single value states as you demonstrated in the video. In the case you have a dependency between state's value then it is NOT advisable to split the state, and better to have a single object state or use the useReducer HOOK. This way grantees always get the latest state value. When states are separated you gain performance by letting react decide when is the best time to store the latest state after you set it to its latest value. You may encounter cases where you are checking one state value before settings another state value and you don't necessarily have the latest value since React hasn't set it yet. It's not a common thing usually things happen fast, but on big applications, it can occur.
@fhkodama
@fhkodama 2 года назад
Pedro, excelente vídeo! Se você tiver outras "best practices", pode fazer mais desse tipo de vídeo que ajuda bem nós que estamos começando! Estou mudando de carreira e seus vídeos estão me ajudando bastante. Fiquei feliz de saber que vc é um brasileiro morando em Vancouver. Eu acabei de chegar em Ottawa. Abração e parabéns!
@PedroTechnologies
@PedroTechnologies 2 года назад
Boaa! Fico feliz em saber que estou ajudando :)
@WarframeCrunch
@WarframeCrunch 2 года назад
Thanks for the first information about rendering. Tutorials I watched just shown how to build on react using components, but they didn't mentioned rendering how it exactly works, so in the future I might made mistake of adding useState on the place where many components are so forcing every component to re-render even if they don't have to. PropType is also useful before I learn TypeScript. Subscribed to you since I just started learning React so I will check other videos later when I end up other tutorials.
@demomicrocrawlerclub
@demomicrocrawlerclub Год назад
Great video. Useful stuff. Thanks a lot.
@mkgenov3691
@mkgenov3691 2 года назад
Good advices! Thanks.
@jccorman5848
@jccorman5848 2 года назад
everything that is related to "best practices", clean coding, simplifying is very useful and hopefully not too complicated to make into a video.
@vimalswaroopj3429
@vimalswaroopj3429 2 года назад
WoW!!! Learnt a lot here :D
@brenoverissimo3846
@brenoverissimo3846 2 года назад
Really interesting video. I'm a beginner in React and I think that this sort of video prevents a lot of dirty code along the way. Thanks!
@charbouy
@charbouy Год назад
Great video it helps me a lot.
@wpxpert98
@wpxpert98 Год назад
Thanks pedro, its a great video, I enjoy it
@rahuldotel5983
@rahuldotel5983 2 года назад
never knew about proptypes thankyou for the exposure 😊😊
@galfrano
@galfrano 2 года назад
good video. quick note on separating states: if you use onsubmit instead, the values change together so it is more concise to keep em together. video idea? react profilers!
@itsmeahmedlukman
@itsmeahmedlukman Год назад
Wow it's so fascinating to be taught by a university student. Most online lecturers tend to be graduate. I am an undergrad student studying comp scie and am just starting to learn react. Found your tutorials really helpful! Keep up the great work! ❤️
@eliyir
@eliyir 2 года назад
Thank you, Pedro!
@rawanBairouti
@rawanBairouti Год назад
This was a fantastic video! Very beneficial and enjoyable at the same time. Keep it up!
@Colstonewall
@Colstonewall 2 года назад
Great vid, Pedro! I enjoyed it. . .Just to make a quick point about Fragments in React, the empty tags as you used is the shortcut. In other words, is short for after importing Fragment. Or, just using . I know this is a nit picky comment, but some beginners get confused about this. Just mentioning this so others may not get confused about it.
@dixxixio
@dixxixio 2 года назад
Thank you for this video! Keep up the good work!
@PedroTechnologies
@PedroTechnologies 2 года назад
Thank you!
@NamNguyen-oz8uj
@NamNguyen-oz8uj 2 года назад
Very useful Pedro, Thank you very much 🎉🙏
@Aspiiire
@Aspiiire 2 года назад
Really amazing content! thank you so much, really useful tips
@Alex.Shalda
@Alex.Shalda 2 месяца назад
Wow! Great video 🎉
@catreunion
@catreunion 2 года назад
Thank you so much!
@yashiel
@yashiel Год назад
really helpful stuff thanks
@adelarsq
@adelarsq 2 года назад
Really good tips! Thanks for share!
@mohammedjoubba318
@mohammedjoubba318 2 года назад
Awesome ! Thank you so much
@PedroTechnologies
@PedroTechnologies 2 года назад
Glad it was helpful!
@chmodkill
@chmodkill 2 года назад
good stuff man!
@anazi
@anazi 2 года назад
Thank you very much Pedro. Your awesome and ypur videos are amazing.
@erictan40
@erictan40 2 года назад
Like your hustle spirit.... keep going. Thanks for sharing this video.
@Mark-iv5dl
@Mark-iv5dl 2 года назад
just found out about your channel awesome man! i subscribed
@PedroTechnologies
@PedroTechnologies 2 года назад
Thanks for subbing!
@emersonjjsouza
@emersonjjsouza 2 года назад
Nice tips and tricks from Brazil to World :)
@sonamohialdin3376
@sonamohialdin3376 Год назад
Awesome tutorial
@taharaezell5166
@taharaezell5166 2 года назад
Awesome information!!
@PedroTechnologies
@PedroTechnologies 2 года назад
Glad it was helpful!
@k303k
@k303k Год назад
Thank you for this amazing video PEDRO! You always motivated me to learn more deep dive about React.
@nages1549
@nages1549 9 месяцев назад
Thanks bro ❤
@SonAyoD
@SonAyoD 2 года назад
Great video!
@mabrarhassan
@mabrarhassan Год назад
Your video is informative. First topic is new addition to my knowledge and others also help remind me to keep away from mistakes.
@quofintech9200
@quofintech9200 2 года назад
Great video Pedro, thanks!
@PedroTechnologies
@PedroTechnologies 2 года назад
Glad you liked it!
@hosamgnaba3205
@hosamgnaba3205 2 года назад
very useful video man, thank you
@jacobleonhardt4421
@jacobleonhardt4421 Год назад
Thanks for the video! Praying you pass your courses.
@jinhu940817
@jinhu940817 2 года назад
senangnya menemukan channel sepert ini. terima kasih.
@yourprogrammer8821
@yourprogrammer8821 2 года назад
Amazing!! Thanks a lot
@PedroTechnologies
@PedroTechnologies 2 года назад
Glad you liked it!
@gledianlalushllari9577
@gledianlalushllari9577 2 года назад
I'm new to react, but my impression was that for single state variables you use useState and for object state you use a reducer. I thought that was the recommendation.
@wesleyjanse6600
@wesleyjanse6600 2 года назад
I think that when you are looking at a state that will only be needed in a certain component you will be looking to use useState, if you are going for a more global state management approach, you could do a setup with reducers and context providers. But if you are new to React, try to understand the basics first and go from there. It's a lot if you try to learn it all at once.
@madhan3658
@madhan3658 2 года назад
Hey Pedro, thanks for the tremendous video, I was about to learn Proptypes as I am not aware of that, Now I came to an idea of Proptypes, thanks bud!! keep up the good work ❤
@PedroTechnologies
@PedroTechnologies 2 года назад
Fantastic! Glad I could help :)
@playmambo9573
@playmambo9573 Год назад
Muchas gracias por los videos. Son excelentes. Estaría muy bien si pudieras hacer uno sobre la arquitectura de proyectos. Cómo empezar desde el diseño del proyecto antes de empezar a escribir código. Existen muy pocos videos de ese tema especializado en React. ¡Gracias por el tiempo que dedicas a compartir tu conocimiento!!
@anazi
@anazi 2 года назад
Please do not hold on sharing knowledge just because the topic is not "cool enough" or "unique enough." We love you
@nickwoodward819
@nickwoodward819 11 месяцев назад
Cool video so far, thanks. Just wanted to quickly comment about your setColor function at 03:16. Should you be using the function parameter of the current color to set the new color? A conditional test there looks like it could potentially be based on stale colors
@nickwoodward819
@nickwoodward819 11 месяцев назад
Love these sorts of video though, so please keep making them!
@arturmavlidov247
@arturmavlidov247 2 года назад
Thanks!
@avgSE81
@avgSE81 2 года назад
Pedro, wiill you please make a video on unit/integration testing?
@erfelipe
@erfelipe 2 года назад
Ótima didática!
@codewithme2412
@codewithme2412 2 года назад
hey pedro what are you using to edit videos ?
@finkyfreak8515
@finkyfreak8515 2 года назад
Good stuff
@abhaytiwari6411
@abhaytiwari6411 2 года назад
Thanks dude
@connergoldberg
@connergoldberg 2 года назад
Hey Pedro, would love to see a redux-thunk integration to continue on with your redux-toolkit series! Thanks
@meetdhanani2174
@meetdhanani2174 2 года назад
Great Knowlagable video, Please make more video on NextJs
@fehmienes5744
@fehmienes5744 2 года назад
Hi Pedro. Thanks for the video. I was checking on youtube about how to document your react app with Jsdoc but I didn’t see any videos in good quality. That might be another suggestion if it interests you. Thanks again.
@detroit7213
@detroit7213 Год назад
I think for handling big forms useful Is useReducer hook
@quofintech9200
@quofintech9200 2 года назад
Pedro, in a larger project do you usually separate compenents in other folders? Or how do you manage it when it has a lot of components? Thanks!
@PedroTechnologies
@PedroTechnologies 2 года назад
If it is a reusable component like a button or an input, I store it in a components folder. But usually i have a pages folder with a bunch of folders related to each page in my website. I did a video on react folder structures if you are interested :)
@mohammedjoubba318
@mohammedjoubba318 2 года назад
I think he has a video explaining how he separates components
@quofintech9200
@quofintech9200 2 года назад
@@PedroTechnologies I will take a look, thanks a lot!
@quofintech9200
@quofintech9200 2 года назад
@@mohammedjoubba318 Thanks Mohammed!
@Sagora123
@Sagora123 2 года назад
​@@quofintech9200 w/ on the job projects, you'll have some hierarchy. Like Pedro said, typically 'pages' has its own separate folder which stores page-level components (Home, Profile, Settings). Components can be broken down into a host of multiple sub-directories. Have custom form components? You can create a Form directory, and store form related components: * components/form/Button.js * components/form/Dropdown.js You have several graph components? (PieChart, BarChart, LineGraph) Store it in a folder called 'graphs. * components/graph/PieChart.js * components/graph/BarChart.js File structure and organization is vital when managing large-scale applications.
@madihamuhammad3799
@madihamuhammad3799 2 года назад
Hi @PedroTech there 2 videos related to Redux toolkit. Basics with redux toolkit and crud also. But for big projects the structure is complicated. there are optional reducers. store is created separate. services also used to get backend data. Have you made any video related to advance redux toolkit ? Or will you have plan to make one? Please reply. Waiting anxiously . Thanks
@lucadifazio2735
@lucadifazio2735 2 года назад
Hi Pedro. In the third Best Practice, if I make the inputs 2-way-bind to the state, don't both ways violate the first Best Practice?
@hamidr8391
@hamidr8391 2 года назад
Please make a video on best practices to organise a bigger project code. Like how to setup layout, routes, pages, components..
@NavjotSingh-wo8hj
@NavjotSingh-wo8hj Год назад
While propTypes are good for debugging at run time, you really want type checking in place so that you're warned about such issues while you're writing code. That's where you need TypeScript or Flow if your want to incrementally add type safety to your JS project
@vigneshwarrv
@vigneshwarrv 2 года назад
hii sir , separating into different component is ideal but what if we want to share state between components.. I mean like having parent component ( form ) with different child component like child1 (inputs for personal data) , child2( inputs for team members ) , child3 ( inputs for work & status updations ) and we need to share those states to parent on submit..
@ahmed7253
@ahmed7253 2 года назад
سوف اكتب هذا بلغتي انت عظيم يا فتى استمر في التقدم و الشروحات العظيمة 💪🏼
@PedroTechnologies
@PedroTechnologies 2 года назад
شكرا لك! زميلتي في السكن تتحدث اللغة العربية أيضًا ، لذا أحاول أن أتعلمها :)
@masaratech
@masaratech 2 года назад
@@PedroTechnologies شكراً لك
@Chriss-cn1ch
@Chriss-cn1ch 2 года назад
@@PedroTechnologies yallaa
@embrace7972
@embrace7972 2 года назад
Awesome.
@profauzan
@profauzan 2 года назад
cool brooo
@ionut-ciprianandrei5946
@ionut-ciprianandrei5946 2 года назад
Could you make a video with stripe for node and react?
@GauravYadav-rv7wx
@GauravYadav-rv7wx 2 года назад
Can you please tell me what is the performance benefits of splitting the state into name, email and age ?
@gabrielmaciel2891
@gabrielmaciel2891 2 года назад
Você é Brasileiro né mano? Seu sobrenome entrega kk to aprendendo mto com seus videos. Obrigado por ajudar agnt!
@mohammedsadiq5729
@mohammedsadiq5729 2 года назад
Finally watched your video after a long time 🙌 phewww!!
@PedroTechnologies
@PedroTechnologies 2 года назад
Welcome back :) You're one of the OG subs!!!
@chaitanyasawant776
@chaitanyasawant776 2 года назад
You can make video on how to use Google api with react ( everything related to google api).
@Anonymousmalayali
@Anonymousmalayali Год назад
Hi sir please make a video for handling many props drilling.20 or 30 props
@yashasjain8114
@yashasjain8114 2 года назад
Great !!!!!!!!
@DuyTran-ss4lu
@DuyTran-ss4lu 2 года назад
Awesome
@aremu_smog
@aremu_smog 2 года назад
Any chance you can make a video how to enable PropTypes in Eslint?
@samandarjumanov1815
@samandarjumanov1815 Год назад
Hey pedro aweome video amazing practice , one whing i wanna mention is can you make a video that best react porjects make us cool at react
@sekhar6753
@sekhar6753 Год назад
can you explain about about which forms can we use, currently i am using react-reative-forms
@amandinelevecq6664
@amandinelevecq6664 2 года назад
Can you make a video on error handling in React please? 😄
@davoodsharifi4769
@davoodsharifi4769 Год назад
thnks
@DanielTruongDev
@DanielTruongDev 2 года назад
Hi Pedro, for the timestamp in the description, if u change the | symbol to a - instead, it’ll automatically add those timestamp in the video ;)
@PedroTechnologies
@PedroTechnologies 2 года назад
Thank you! For some reason this time it didn't automatically put but the way i did it usually work. But thank you for pointing it out :)
@DanielTruongDev
@DanielTruongDev 2 года назад
@@PedroTechnologies and you also have to add a 0:00 timestamp I believed
@tanlor
@tanlor 2 года назад
Fala Pedro! Estou estudando e o que me faz decidir ou não aplicar algo no meu projeto é a performance. Por exemplo, no Form que você postou usando e.target.value e setando States faz o componente renderizar, impactando performance, então eu uso a lib ''react-hook-form'' que faz um track dos inputs sem precisar mudar States e renderizar o component, impactando performance. Tem alguma outra lib ou métodos que você prefere usar por conta da performance da aplicação? Faz um vídeo sobre performance! Valeu :)
@PedroTechnologies
@PedroTechnologies 2 года назад
Boa Kleyton, para projectos grandes eu uso a lib Formik. Eu tenho videos tanto sobre formik quanto sobre react-hook-form. Os dois são muito bons! O exemplo no video foi só para explicar mesmo
@tanlor
@tanlor 2 года назад
@@PedroTechnologies Vou ver o do Formik 🥰
@mayatundeolawale3
@mayatundeolawale3 2 года назад
Can you please build a complete responsive react project with bootstrap and little css
@konkerouf
@konkerouf 2 года назад
man, if you need to split a form state into multiple states to keep it performant, i think there are other parts of your form to optimize.... How big is your form? 2.5M inputs?
@dev-rachid
@dev-rachid 2 года назад
Nextjs tutorial please. Thanks a lot 👍
@johnnymnemonic6703
@johnnymnemonic6703 2 года назад
Hi Pedro, Very informative and nice video. Please 🙏 don’t take it as a critique but constructive feedback to make your videos better. You are using the mouse to highlight code too much to the point it is slightly distracting even at normal speed. I like to watch videos at 1.5 speed and it the mouse highlighting can get very distracting and slightly irritating. Try to minimise highlighting with the mouse to the minimum or necessary. For example, the fragment section you were explaining returning siblings you kept on highlighting the tags multiple times but it was already explained that they are siblings. I liked the video and really really appreciate the video and please take this as a recommendation and not a critique.
@PedroTechnologies
@PedroTechnologies 2 года назад
Sorry about that hahaha I always try to take criticism as constructive and I appreciate your comment! I do that because I am thinking what I am going to say hahaha but I will try to stop :) I might get like a fidget thing to play with while explaining
@namucho266
@namucho266 Год назад
Can you share the official doc from React team in regards to 9:00 part?
@karis7539
@karis7539 2 года назад
10:50 you could just make it as a form and get fields values onSubmit
@hassamulhaq7762
@hassamulhaq7762 Год назад
propsType no more comes with React, need to install separately using npm. Predro your performance based and best practices video really helpful. I learnt a lot from this channel.
@krishnarajasiva9351
@krishnarajasiva9351 2 года назад
Hi Pedro.... Can you drop one video for webpack.config.js clear explanation??
@aristidescruz1414
@aristidescruz1414 2 года назад
A video about testing in react
@stephen7715
@stephen7715 Год назад
15:27 "Age is a number" 💀
@PedroTechnologies
@PedroTechnologies Год назад
I didn't mean it that way lmaoo
@andrewaghoghovwia1948
@andrewaghoghovwia1948 2 года назад
Thanks Pedro. This was very informative . Please can you do a video on testing custom form inputs? Thanks
@khwajanamatullahseddiqy6999
It was good.
@augischadiegils.5109
@augischadiegils.5109 2 года назад
❤️❤️❤️❤️❤️❤️
@fuhoo5836
@fuhoo5836 2 года назад
just use a form project to handle inputs... typescript is a hard requirement.
@ivanivan9984
@ivanivan9984 Год назад
I'm not agree with the practice to separate same essence data by difference useState collections. I do it only when it is difference essences. For example: const [wordState, setWordState] = useState({ name: "", translation: "", type: "" }); const [modalState, setModalState] = useState({ show: true, text: "" }); Because another way it will be a mess: const [wordNameState, setWordNameState] = useState(""); const [wordTranslationState, setWordTranslationState] = useState(""); const [wordTypeState, setWordTypeState] = useState(""); const [modalShowState, setModalShowState] = useState(true); const [modalTextState, setModalTextState] = useState(""); Too many variables, hard to read. I also wanted to notice that there is also a good practice common for all programming to name variables the most understandable way. So looking into my example the variable with the name wordState is much clearer than if it could be just word, because word can be only text, it can come as a prop and here you know for sure it's a state var and setWordState is a setter of this var.
@aidenberzins
@aidenberzins 11 месяцев назад
Why not just use a reducer rather than multiple useStates hooks?
Далее
All The JavaScript You Need To Know For React
28:00
Просмотров 563 тыс.
это самое вкусное блюдо
00:12
Просмотров 1,2 млн
🥔 Sloppy Joe Potato Casserole ~#Shorts
00:23
Просмотров 3,9 млн
МАЛОЙ И РЕЧКА
00:36
Просмотров 296 тыс.
Is this the perfect React app? - Code Review
11:02
Просмотров 37 тыс.
Speed Up Your React Apps With Code Splitting
16:50
Просмотров 369 тыс.
Stop Doing this as a React Developer
12:27
Просмотров 159 тыс.
6 State Mistakes Every Junior React Developer Makes
15:53
5 Pro-Level React Do's & Don'ts
30:06
Просмотров 174 тыс.
Why Signals Are Better Than React Hooks
16:30
Просмотров 456 тыс.
React Like a Pro: React Best Practices
9:55
Просмотров 9 тыс.
#miniphone
0:16
Просмотров 3,5 млн
Все розовые iPhone 💕
0:51
Просмотров 225 тыс.