Layout Components | React Design Pattern -2

แชร์
ฝัง
  • เผยแพร่เมื่อ 3 พ.ย. 2024

ความคิดเห็น • 99

  • @PsychoGod9898
    @PsychoGod9898 ปีที่แล้ว +9

    Overall great tutorial with some valuable concepts.
    Just one thing: this pattern
    ``
    is quite dangerous. It can result in unexpected runtime errors when the prop name in SmallPersonListItem changes or this componentn later requires additional props. And while the first one can easily be fixed, the later one will basically be impossible to fix without changing the api of RegularList wich, as it will be most likely a very widely used component, can be quite dangerous as well.
    A much better pattern would be to use render props instead:
    ` } />`
    This way you can get proper TypeScript support for all the props of SmallPersonListItem (or at least proper IDE support when using JS). And the TypeScript support becomes even better when you use inferred generics in RegularList:
    ```
    interface ListProps {
    items: Array;
    renderItem: (item: T) => ReactNode;
    }
    const RegularList = ({ items, renderItem }: ListProps) => {
    return (

    {items.map((item, index) => (
    {renderItem(item)}
    ))}

    );
    };
    ```

    • @Saq-t5k
      @Saq-t5k 9 หลายเดือนก่อน

      I Agree with you bro, your version I very liked

    • @CodingWithMrM
      @CodingWithMrM  9 หลายเดือนก่อน

      I don’t think so it will throw the errors or dangerous because you just need to pass the props however you can pass it though

    • @JSDev776
      @JSDev776 6 หลายเดือนก่อน

      thanks, i was about to comment this, as i work for a fintech giant and we use this.

  • @propertiesofgabe3865
    @propertiesofgabe3865 2 ปีที่แล้ว +14

    This video is a gold mine. So clear and concise between the instruction, the logic behind the code, and even the variable names. Everything seems so constructed with thought in mind to make it as easy for the viewer to understand as possible. I very much appreciate this video, as I'm sure many others do. Thank you very much! Easily earned a new Sub!!

    • @CodingWithMrM
      @CodingWithMrM  2 ปีที่แล้ว

      Thanks a lot for your valuable comment.
      Thanks for subscribing,
      Please support me to gain more subscribers and to share content to the useful people's who are indeed ☺

  • @DoheSeGyaan
    @DoheSeGyaan 11 หลายเดือนก่อน +2

    Can't find github link in description can you provide?

    • @CodingWithMrM
      @CodingWithMrM  9 หลายเดือนก่อน +1

      Yeah sorry. I lost those files. I formatted my laptop and lost all those files. In my next video I’ll provide it

  • @egorushakov9049
    @egorushakov9049 ปีที่แล้ว +3

    Layout design pattern for lists is neat! Thanks for making this course available.

    • @CodingWithMrM
      @CodingWithMrM  ปีที่แล้ว

      Thanks for your valuable comment. Please support me by subscribing and sharing my videos to others. Don’t forget to turn on notifications bell for more updates

  • @BcomingHIM
    @BcomingHIM 9 หลายเดือนก่อน +1

    Amidst a mountain of react tutorials. this stands out as mount everest. Amazing Stuff.

    • @CodingWithMrM
      @CodingWithMrM  9 หลายเดือนก่อน

      Thanks a lot for your valuable comment. Please support me by subscribing, like and don’t forget to turn on notifications bell for more amazing content soon I’ll upload moree

  • @XinrongHan
    @XinrongHan 8 หลายเดือนก่อน +2

    Hi! I love you courses, where can I find the exercise files source code?

    • @CodingWithMrM
      @CodingWithMrM  8 หลายเดือนก่อน +1

      Thanks a lot Han, unfortunately my laptop got formatted and I lost files but please don’t worry l I’ll try to figure it out and get the code hehe
      Please do support me
      By subscribing, sharing and turn on notifications bell 😊

  • @mtsurov
    @mtsurov ปีที่แล้ว +15

    "Dark Theme" please, ... this is burning my retina. (many of us are watching this on laptop in darkness)

    • @s-qc9ns
      @s-qc9ns 4 หลายเดือนก่อน +3

      even though its dark mode, you shouldn't watch any screens without background lights on.
      When thee is no bg light our iris is wide open and the directed light from screens damages our retina.

    • @CodingWithMrM
      @CodingWithMrM  4 หลายเดือนก่อน

      @s-qc9ns yeah that’s right

  • @ikurbano
    @ikurbano 2 ปีที่แล้ว +6

    Mr. M, you are the reason why there are so many programmers without computer science degree, as well as, the reason why we can effectively compete with the college graduates! It's hard to overestimate the value of this series! Thank you very much!!! I stay tuned now.

    • @CodingWithMrM
      @CodingWithMrM  2 ปีที่แล้ว

      Please support me by sharing my videos and don't forget to like, share, subscribe and turn on notifications bell

    • @govinda399
      @govinda399 ปีที่แล้ว +2

      WHAT DO YOU THINK? COMPUTER SCIENCE STUDENT ARE TAUGHT PROGRAMMING OR REACT DURING DEGREE? NO BRO.

    • @CodingWithMrM
      @CodingWithMrM  ปีที่แล้ว

      Of course not at all, CS student just get the knowledge instead of the dev skills, skills need to be learn, we can't get it from the degree

  • @animeprofiles2077
    @animeprofiles2077 2 ปีที่แล้ว +3

    Dude , your channel is the Gold , we sadly need to dig for among all those cliche tutorials emphasizing the same trendy material !
    Anyways Massive Respect for you to teach these Design Patterns !

    • @CodingWithMrM
      @CodingWithMrM  2 ปีที่แล้ว

      Thanks a lot buddy
      Please support me by sharing my videos and don't forget to like, share, subscribe and turn on notifications bell

  • @govinda399
    @govinda399 ปีที่แล้ว +1

    I was asked about design pattern in React and this was the only reason I was not qualified. now i understood, thank you, your video is very helpful to me.

    • @CodingWithMrM
      @CodingWithMrM  ปีที่แล้ว +1

      I'm happy, it's helpful for you and the other developers like you,
      Please support me by subscribe, like and share to other developers like you and don't forget to turn on notifications bell

    • @govinda399
      @govinda399 ปีที่แล้ว

      @@CodingWithMrM already subscribed, liked and i will share to the needful.

  • @DQSownahmoon
    @DQSownahmoon 2 ปีที่แล้ว +3

    Lovely course, I just wanted to add that using the file type .jsx instead of .js is probably wise. I found this out when setting up React to work with Vite where I had to rename aaallll of my components to use jsx instead.

    • @CodingWithMrM
      @CodingWithMrM  2 ปีที่แล้ว

      Yeah, sometimes vite throws that error with the extension, but it's a good practice to use jsx instead of js, as its react components.

  • @ihortsarenko3119
    @ihortsarenko3119 ปีที่แล้ว +3

    Thanks for the video. I see some reusable components here, but I don't see the pattern here tbh. Maybe it's worth to make a summary in the end... kinda... tend to use children components rather then pass components as props, if we talk about layouts.
    Also I'd like to hear when it's worth to create another kind of List component? like you did with Numbered list. We could add a prop, called `numbered` and tweak the regular List component to support it.

    • @CodingWithMrM
      @CodingWithMrM  ปีที่แล้ว

      Yeah we can do that.
      Please support me by subscribing and sharing my videos to others. Don’t forget to turn on notifications bell for more updates

  • @sachinkhadka249
    @sachinkhadka249 2 ปีที่แล้ว +7

    Great video but just a question I dont really understand how we can style the list item component in another component.If i want to style the h3 tag of the list item component from its parent component how will I exactly achieve it.

    • @vijayroy7634
      @vijayroy7634 2 ปีที่แล้ว +2

      please I encourage viewer to vote this question because this is really a very good question. I would like to seek the attention of the Mr. M to this question or someone who has answer to this. Thank you

    • @rajeev7842
      @rajeev7842 2 ปีที่แล้ว +2

      You can pass an object to the resourceName. Like this:-
      resourceName={{name: 'product', customStyle:"backgroundColor:'red'"}}
      Something like this..

    • @CodingWithMrM
      @CodingWithMrM  2 ปีที่แล้ว

      You can do it by giving the class name or id it's easy though ☺

  • @yanngranjon
    @yanngranjon ปีที่แล้ว +2

    11:48
    leftWeight={1} and rightWeight={3}
    doesn't give you one third as you said but a quarter
    basically it's 1/(1+3) = 1/4 and 3/(1+3) = 3/4
    If you'd wanted one third you should have, instead, set:
    leftWeight={1} and rightWeight={2}
    -> left: 1/(1+2) = 1/3, right: 2/(1+2) = 2/3
    If you want a half:
    leftWeight={1} and rightWeight={1}
    -> left: 1/(1+1) = 1/2, right: 1/(1+1) = 1/2
    etc (:

    • @pinrruchou8187
      @pinrruchou8187 10 หลายเดือนก่อน +1

      He said left weight will be one third as wide as right weight, in this condition leftweight = 1 , rightweight = 3 is correct.

    • @yanngranjon
      @yanngranjon 10 หลายเดือนก่อน +1

      @pinrruchou8187 indeed, my bad (:

    • @CodingWithMrM
      @CodingWithMrM  10 หลายเดือนก่อน

      @yanngranjon hehe okay. Don’t forget to subscribe my channel and support me

  • @RaymondJonesAdvice
    @RaymondJonesAdvice ปีที่แล้ว +1

    Great video, so helpful

    • @CodingWithMrM
      @CodingWithMrM  ปีที่แล้ว

      Thanks a lot
      Please support me by subscribing and sharing my videos to others. Don’t forget to turn on notifications bell for more updates

  • @MegaPranav99
    @MegaPranav99 ปีที่แล้ว +1

    You’re a lifesaver

    • @CodingWithMrM
      @CodingWithMrM  ปีที่แล้ว

      Thanks man please support me
      Please support me by subscribing and sharing my videos to others. Don’t forget to turn on notifications bell for more updates

  • @MrDummy-sn5rb
    @MrDummy-sn5rb 2 ปีที่แล้ว +1

    Great video to learn pro code

    • @CodingWithMrM
      @CodingWithMrM  2 ปีที่แล้ว

      Thanks please support me by sharing, liking and subscribing my channel

  • @orestborovets2140
    @orestborovets2140 ปีที่แล้ว +1

    Awesome. Many thanks

    • @CodingWithMrM
      @CodingWithMrM  ปีที่แล้ว

      Thanks a lot
      Please do support me by subscribing, sharing my videos and don't forget to turn on notifications bell 🛎

  • @Rick-ng3lr
    @Rick-ng3lr 2 ปีที่แล้ว +2

    Thank you for this clear and educational content. Keep up the good work. Can’t wait to see more. 😃👍🏻

    • @CodingWithMrM
      @CodingWithMrM  2 ปีที่แล้ว +2

      Your welcome
      Yes I’ll upload today one more part of it.
      Don’t forget to subscribe and turn on notifications and share to them who need of it 😊

  • @suarezmessi676
    @suarezmessi676 ปีที่แล้ว +2

    Great video, I have one question at the end of the layout pattern why are we keeping leftweight = 1 and rightweight = 1.
    Why are we assigning a number to these when we already do that in the splitscreen prop?

    • @davidemilan59
      @davidemilan59 ปีที่แล้ว +1

      I'm pretty sure those are just default values: this way even if we omit passing those props from the parent component, they will still have a value of 1

    • @CodingWithMrM
      @CodingWithMrM  ปีที่แล้ว

      It’s because of default value

  • @coder3123
    @coder3123 ปีที่แล้ว +1

    love this, I am trying to follow along using typescript, and struggling a bit, please if you have a video of converting js components to typescript components that would help.
    Thanks

    • @CodingWithMrM
      @CodingWithMrM  ปีที่แล้ว

      Great suggestion! I’ll do that in next video. Please do support me by sharing my videos to others and don’t forget to subscribe and turn on notifications bell

  • @rutvikshah4589
    @rutvikshah4589 ปีที่แล้ว +1

    THANK YOU !

    • @CodingWithMrM
      @CodingWithMrM  ปีที่แล้ว

      You're welcome!
      Please support me by subscribing and sharing my videos to others. Don’t forget to turn on notifications bell for more updates

  • @berzolka
    @berzolka ปีที่แล้ว +1

    Hi!
    In the snippet above:
    Are the external curly brackets brackets for the react dynamic values?
    So these brakets aren't javascript object literal braces, are they?
    If they are just javascript object literal braces we just copy an object to another object with the same structure. (with the spread operator)
    Actually, this is a react question, not related to the design pattern.
    Thanks!

    • @CodingWithMrM
      @CodingWithMrM  ปีที่แล้ว +1

      Hai yeah!
      Thanks for your question about the code snippet. You're absolutely right! The curly braces in JSX are used for dynamic values in React, but they're not limited to React - they're a JavaScript thing.
      And yes, the spread operator (`...`) is handy for copying object properties, a cool JavaScript trick!
      Feel free to hit me up if you have more questions. Happy coding!
      Please support me by subscribing and sharing my videos to others. Don’t forget to turn on notifications bell for more updates

  • @TheMrtastee
    @TheMrtastee 2 ปีที่แล้ว +2

    Great content!!
    Just wondering if you have a rule of thumb or some kind of hint that tells you where to stop adding extra logic to components in order to make them more flexible.
    ie, You can easily add an extra boolean prop to regular list component that tells you if you want to display the index value and making the list "numeric" in the process. No need for an extra component to achieve that, since you barely changed the code.

    • @CodingWithMrM
      @CodingWithMrM  2 ปีที่แล้ว

      Thanks, yeah we can do that too

  • @oscarchan5684
    @oscarchan5684 2 ปีที่แล้ว +1

    Thank you! Really helpful!

    • @CodingWithMrM
      @CodingWithMrM  2 ปีที่แล้ว

      You're welcome
      Don't forget to like, share, subscribe and turn on notifications bell 🛎

  • @natalias.2267
    @natalias.2267 ปีที่แล้ว +2

    where I can get from the exercises files ?

    • @CodingWithMrM
      @CodingWithMrM  9 หลายเดือนก่อน

      I lost those files sorry

  • @wishmeheaven
    @wishmeheaven ปีที่แล้ว +1

    Thank you for this video and for the entire series.
    As far as I'm aware of Styled-Components is a package which take care of styling in React.
    Maybe they use some type of design pattern, but you represent them as if they are themselves a design pattern, while no official documanet of react about design patterns (as far as I found) doesn't even mentioned styling as an example of one of the design pattern forms/types.
    I'm not sure I understand the purpose of this video, if you installed NPM to represent a design pattern while some of us working with Bootstraps, Material UI, or Tailwind.
    What is even the name of the design pattern that you are showing here?
    What am I missing here..?
    I'll be happy to understand.

    • @CodingWithMrM
      @CodingWithMrM  ปีที่แล้ว +1

      Please go through the entire playlist and here’s some of the information.
      Design patterns are reusable solutions to commonly occurring problems in software design. React, being a popular JavaScript library for building user interfaces, has several design patterns that are commonly used to solve common problems.
      Here are some common design patterns in React:
      Render Props Pattern: This pattern involves passing a function as a prop to a component which can then be called to render content in the component. This allows for more flexibility in creating reusable components.
      Higher-Order Components Pattern: This pattern involves creating a function that takes a component and returns a new component with additional functionality. This can be useful for adding common functionality, such as data fetching or authentication, to multiple components.
      Container-Component Pattern: This pattern involves separating a component into two parts: a container component that manages state and data, and a presentational component that renders the UI. This can make the code more organized and easier to understand.
      Controlled Components Pattern: This pattern involves controlling the state of form inputs in a component by passing their values and onChange events as props. This can make it easier to manage the state of form data and make the component more reusable.
      Redux Pattern: This pattern involves using the Redux library to manage state across multiple components. This can make it easier to manage complex state and ensure consistency across the application.
      These are just a few examples of the design patterns used in React. There are many other patterns that can be used to solve different problems, and developers often combine multiple patterns to create more complex solutions.
      Please do support my channel

  • @traviswhittington4374
    @traviswhittington4374 ปีที่แล้ว +1

    Awesome video! This gave me some inspiration for refactoring some of my old code. I do have a question regarding your layout pattern for lists. How does the pattern you showed differ , or why is it a better approach than say, creating a list component with an actual unordered list or ordered list that maps over the items themselves and nests them within the ul or ol provided by RegularList or NumberedList. My thinking was that a list item is not the list itself but a single child element of one. It could be that I’m confining my thinking of lists to actual list item elements within html list elements. I hope the question makes sense. This has been an excellent tutorial.

    • @CodingWithMrM
      @CodingWithMrM  ปีที่แล้ว

      Yes you're right it's just making us easr to make one reusable component to loop through the items and make a list. It can be either ordered or unordered its depend on use case, for making as per that you just need to pass one more props like isOrdered if it's true then make it as ordered list or else unordered. I hope you got me.
      Thanks for the feedback.
      Please do support me by subscribing my channel and share my video to everyone who keen to learn and don't forget to turn on notifications bell for new videos

  • @abinesh-e
    @abinesh-e 2 ปีที่แล้ว +1

    Hello Mr.M 😀,
    I love this course. you made me think out of the box. I have one small question. your code looks short and sweet. How ever if you develop a huge web applications containing 100's of components and things. The programmers how are viewing our code for the first time will feel difficult right? Because this will increase the complexity while viewing. if we need a good quality code our application should have lots of state less components right?. is it recommended for bigger and bigger applications?

    • @CodingWithMrM
      @CodingWithMrM  ปีที่แล้ว

      Yes that's true, simple code is for better understanding and optimizing, for a new coder it'll take time to understand, for the experience coders then can love your code easily

  • @tudoresan3031
    @tudoresan3031 2 ปีที่แล้ว +1

    Very nice!

    • @CodingWithMrM
      @CodingWithMrM  2 ปีที่แล้ว

      Don't forget to like, share, subscribe and turn on notifications bell please help me by supporting my channel ☺

  • @atvan933
    @atvan933 2 ปีที่แล้ว +1

    const [left, right] = children is amazing !

    • @CodingWithMrM
      @CodingWithMrM  2 ปีที่แล้ว

      Thanks
      Don't forget to like, share, subscribe and turn on notifications bell 🛎

  • @beratgenc7695
    @beratgenc7695 2 ปีที่แล้ว +1

    thank you

    • @CodingWithMrM
      @CodingWithMrM  2 ปีที่แล้ว

      You're welcome
      Don't forget to like, share, subscribe and turn on notifications bell 🛎

  • @cdhit
    @cdhit 2 ปีที่แล้ว +1

    This is awesome

  • @shafinazyasin7012
    @shafinazyasin7012 ปีที่แล้ว +1

    I have tried following this code but I am stuck with the left and right that you have defined. did you install any library for that? I'm getting the error that it is undefined.

    • @CodingWithMrM
      @CodingWithMrM  ปีที่แล้ว

      No I haven’t installed any. Sorry for late reply. You can connect me on fb and we can solve it

  • @jbc5126
    @jbc5126 2 ปีที่แล้ว +4

    the styled components library is pretty cool but from a learning perspective I'd much prefer to see how to write these with vanilla react first and not have the dependency then if I want add a helper class I can but I will understand what is running underneath.

    • @rajeev7842
      @rajeev7842 2 ปีที่แล้ว +1

      styled component is doing nothing here, if you understand the concept, it is easily reproducible with vanilla react as well.
      Styled components is just for styling and nothing else..

    • @CodingWithMrM
      @CodingWithMrM  2 ปีที่แล้ว

      Yeah but in industry we don't use all those we go along with the libraries

  • @lekkyjayz6294
    @lekkyjayz6294 2 ปีที่แล้ว +1

    How can we animate the modal to fade in and out?

    • @CodingWithMrM
      @CodingWithMrM  2 ปีที่แล้ว

      With the css you can do that, check my css videos

  • @thinBillyBoy
    @thinBillyBoy ปีที่แล้ว +1

    Dude im dumb as a door how would one style them later on? 😮

    • @CodingWithMrM
      @CodingWithMrM  ปีที่แล้ว

      Ahh could you send me the question on my instagram so I might can help you

  • @splusmm
    @splusmm ปีที่แล้ว +2

    can you provide github of your code

    • @CodingWithMrM
      @CodingWithMrM  ปีที่แล้ว

      Once I’m recover then I’ll update it

  • @ShivaPal-o4k
    @ShivaPal-o4k ปีที่แล้ว +1

    congrats for your 500th like😊✨, nice explanation on this topic ... (mza aa gya guru : in hindi(❁´◡`❁))

    • @CodingWithMrM
      @CodingWithMrM  ปีที่แล้ว

      Thanks a lot bro. Thanks for the 500th like.
      Please do support me by subscribing my channel and share my videos other people’s who are looking for coding tutorials.
      I just started editing one more new tutorial heheh.
      Don’t forget to subscribe and turn on notifications bell 😉

  • @muhammadtanko9234
    @muhammadtanko9234 6 หลายเดือนก่อน +2

    github link please

    • @CodingWithMrM
      @CodingWithMrM  6 หลายเดือนก่อน +1

      Sorry I need to search because I lost it my old account

  • @bri7374
    @bri7374 2 ปีที่แล้ว +1

    ⭐ Promo-SM!!

  • @miss-ndeya_Dev
    @miss-ndeya_Dev 6 หลายเดือนก่อน +1

    Hello I would like to know where the project startup folder is located

    • @CodingWithMrM
      @CodingWithMrM  6 หลายเดือนก่อน

      You can follow the video

  • @wishmeheaven
    @wishmeheaven ปีที่แล้ว +1

    Thank you for this video and for the entire series.
    As far as I'm aware of Styled-Components is a package which take care of styling in React.
    Maybe they use some type of design pattern, but you represent them as if they are themselves a design pattern, while no official documanet of react about design patterns (as far as I found) doesn't even mentioned styling as an example of one of the design pattern forms/types.
    I'm not sure I understand the purpose of this video, if you installed NPM to represent a design pattern while some of us working with Bootstraps, Material UI, or Tailwind.
    What is even the name of the design pattern that you are showing here?
    What am I missing here..?
    I'll be happy to understand.

    • @CodingWithMrM
      @CodingWithMrM  ปีที่แล้ว +1

      Please go through the entire videos playlist.
      Design patterns are reusable solutions to commonly occurring problems in software design. React, being a popular JavaScript library for building user interfaces, has several design patterns that are commonly used to solve common problems.
      Here are some common design patterns in React:
      Render Props Pattern: This pattern involves passing a function as a prop to a component which can then be called to render content in the component. This allows for more flexibility in creating reusable components.
      Higher-Order Components Pattern: This pattern involves creating a function that takes a component and returns a new component with additional functionality. This can be useful for adding common functionality, such as data fetching or authentication, to multiple components.
      Container-Component Pattern: This pattern involves separating a component into two parts: a container component that manages state and data, and a presentational component that renders the UI. This can make the code more organized and easier to understand.
      Controlled Components Pattern: This pattern involves controlling the state of form inputs in a component by passing their values and onChange events as props. This can make it easier to manage the state of form data and make the component more reusable.
      Redux Pattern: This pattern involves using the Redux library to manage state across multiple components. This can make it easier to manage complex state and ensure consistency across the application.
      These are just a few examples of the design patterns used in React. There are many other patterns that can be used to solve different problems, and developers often combine multiple patterns to create more complex solutions.