Design patterns in React

Design patterns in React

Cosden Solutions

6 месяцев назад

137,441 Просмотров

Ссылки и html тэги не поддерживаются


Комментарии:

@apiro123
@apiro123 - 29.10.2023 19:02

A series in design pattern would be great

Ответить
@jitujahagirdar613
@jitujahagirdar613 - 28.01.2024 00:24

and i would like to know how to give answer please explain about your fronted project architecture ? give your sample react project architecture example .!

Ответить
@worldwide6626
@worldwide6626 - 14.01.2024 15:53

Lmao this is exactly what my company uses

Ответить
@JamesIsbellUK
@JamesIsbellUK - 04.01.2024 21:19

SRP is a good pattern but can lead to the following drawbacks: excessive fragmentation, increased boilerplate code, decreased readability, difficulty in debugging, and an increased onboarding time for developers.

For small and even some medium-sized projects, sometimes it's just simpler and easier to AVOID breaking things down into multiple responsibilities and files. Sometimes it IS more readable if it's in a single place.

Ответить
@___jd
@___jd - 02.01.2024 09:29

I would argue that PostFeed should handle the Post fetching itself. Makes more sense than the HomePage which is really just a visual container.

Ответить
@mihaistoica4831
@mihaistoica4831 - 20.12.2023 19:57

I don't think naming Design Pattern is right for this type of content. You are presenting good practices for React and Single Responsability Principle Anyway, interesting video, keep up the good work!

Ответить
@mokhtariabdelmadjid2977
@mokhtariabdelmadjid2977 - 20.12.2023 18:52

compound component is just adding more layers of complexity, just keep everything simple and easier we dont need a context or a hook for a simple select that absurd

Ответить
@pixyoutube538
@pixyoutube538 - 17.12.2023 16:48

Thanks a lot bro, really great video

Ответить
@ptolemyhenson6838
@ptolemyhenson6838 - 17.12.2023 05:48

Why is every react component put in a separate file, even the ones that are related to each other and could be easily navigated within the same file?

Ответить
@harrybilney9096
@harrybilney9096 - 11.12.2023 23:46

The only thing I would say about having your fetching and state in your parent component is that when you update that data, your whole page will reload, not just the componants using the data.

Ответить
@guitarcrax127
@guitarcrax127 - 11.12.2023 17:02

Love your videos man. Find them very helpful. I’m an experienced backend developer, finally biting the bullet and reaching myself react (if that’s at all helpful info).

Making my way through every videos you’ve made lol

Ответить
@user-py5zu9pb8u
@user-py5zu9pb8u - 04.12.2023 17:00

thanks

Ответить
@ukaszkisicki7862
@ukaszkisicki7862 - 04.12.2023 02:19

why not fech posts in the postFeed. PostFeed is the owner of these posts. I'd do the fetching there

Ответить
@ekchills6948
@ekchills6948 - 02.12.2023 22:57

How come I'm not subscribed to this channel. Your contents are amazing

Ответить
@arihantbedagkar7678
@arihantbedagkar7678 - 02.12.2023 18:00

The last design pattern greatly helped me structure my code better. Thanks for the video. Appreciate if you can add some more design patterns.

Ответить
@webcodeuniversity
@webcodeuniversity - 29.11.2023 17:27

The SRP is arguable here, for this example, homepage component should not be responsible for fetching posts, that's a responsibility for Posts component to do, imagine that homepage has other components that need some data from an API, so the homepage component will be a mess, therefore, we'll be violating SRP. Also the last patten is arguable indeed, if we do that for every component, then we're losing colocation principle which I think it's more meaningful than just move things around, instead I think smart/dump components pattern would make much sense in such situation instead of using custom hooks. Thanks for the video though

Ответить
@theused0321
@theused0321 - 29.11.2023 00:37

Never seen or used compound component pattern before. Very interesting. I'm curious in what other real world scenarios it would be beneficial to use. Thanks!

Ответить
@dadya_denis
@dadya_denis - 28.11.2023 22:57

Select component are not good enough to show it even for junior developers, cause even within Design Pattern its a bad practice, cause you store the view and the logic of the context inside one file, that incorrect in any case.

Ответить
@chicao4896
@chicao4896 - 28.11.2023 21:03

I find it wild that it takes 70 lines of code to make a select component in React. Great video though.

Ответить
@ayansinha5000
@ayansinha5000 - 26.11.2023 09:24

Can we get this codebase or any github reop to view this example?

Ответить
@aer1th621
@aer1th621 - 24.11.2023 10:26

can I have github repos?

Ответить
@giovannitonussi3746
@giovannitonussi3746 - 22.11.2023 01:56

I have done all of those things before, glad to hear that they are good practices 😅

Ответить
@mohamedabdelhalim9892
@mohamedabdelhalim9892 - 21.11.2023 13:53

can we isolate the logic code in a components that uses that conditional rendering depending on states for example?

Ответить
@PedroBulloJr
@PedroBulloJr - 20.11.2023 18:08

Awesome! You could highlight keywords.

Ответить
@fouadchahd2969
@fouadchahd2969 - 20.11.2023 17:33

Is the last example correct ? The useSignInHooks will be triggered on each render no!?

Ответить
@brianmeyer3050
@brianmeyer3050 - 18.11.2023 21:07

The Select context option feels unnesarily complex. Custom hooks + useContext for a native form element? You mention that it's nice because now it's a simple and reusable component, but you've created something that is finicky, difficult to understand and hard to maintain. That's the opposite of a senior design pattern.

Ответить
@thehelldesk5463
@thehelldesk5463 - 15.11.2023 07:13

I learned nothing, but it should be a good introduction for begginers maybe

Ответить
@angthapyeuquan5409
@angthapyeuquan5409 - 15.11.2023 04:27

Hi, I wonder about the last pattern 'extract useEffect to other files', if we have too many dependencies related to useEffect such as the variables from useState for checking, how can we handle that?

Ответить
@luc.kasnix
@luc.kasnix - 14.11.2023 13:49

The useSignInPage does not have a single responsibility.

Ответить
@zkabadu
@zkabadu - 09.11.2023 23:13

Talks about SRP, doesn't do SRP in its best way: your outer component does not do one thing, but two: it renders the component and it fetches the data. Therefore you break SRP 😬

Ответить
@erfanmo1468
@erfanmo1468 - 09.11.2023 12:28

how did you make the functions sticky in your vscode ?!

Ответить
@michaelm106
@michaelm106 - 08.11.2023 23:12

It's always interesting to see where someone draws the line on single responsibility.

Ответить
@alfonsoalejandroespinosade1728
@alfonsoalejandroespinosade1728 - 08.11.2023 18:46

i think the right name of the pattern is not feature components, is compound components,

Ответить
@robwatson826
@robwatson826 - 08.11.2023 14:03

That was a really interesting video! Thanks for sharing.

A question about extracting logic into Hooks - how do you share state from the hooks back into the component itself? Would you return a big object full of properties similar to how useState works?

Ответить
@michaelkorolev1413
@michaelkorolev1413 - 07.11.2023 17:17

Great video! However, there is something that is bothering me. Why should we reinvent the Select behavior when it's already implemented by the browser?

But the pattern is awesome and should be utilized.

Ответить
@mauriciabad
@mauriciabad - 07.11.2023 00:57

Great video! I only disagree in the single responsability part, because in many cases it's not worth the effort of splitting things up, and you didn't dig into how to decide when to use the pattern.

Ответить
@REPOORTEHT
@REPOORTEHT - 06.11.2023 11:09

Last one : chef's kiss.

Ответить
@joaobonsegno126
@joaobonsegno126 - 06.11.2023 07:54

If you have a PostFeed component that is responsible for rendering the posts, why fetch them in the parent component? If PostFeed has the responsibility to deal with the post feed (obviously), isn't it better to let it fetch its components and remove this responsibility from the parent?

Ответить
@avinashgodvin9900
@avinashgodvin9900 - 05.11.2023 17:31

Wow , Great explanation !
Thank you : )

Ответить
@Forshen
@Forshen - 03.11.2023 21:06

'single responsibility principle' is an priniple. a.k.a. a guideline. Not a Design Pattern.
EDIT: I see 0 Design Patterns here. Just code separation, no technical problem solving.

Ответить
@ameer6168
@ameer6168 - 03.11.2023 17:10

I don't think it matters seniors are still going to use the most fkd up pattern in the existence

Ответить
@elramtv
@elramtv - 03.11.2023 09:49

// @ts-no-senior-check

Ответить
@emapeire
@emapeire - 02.11.2023 21:00

Thanks to show this!

Ответить
@rotivanov
@rotivanov - 02.11.2023 19:07

Hey Cosden, thanks a lot for sharing your knowledge with us. Which monitor do you use for your mac? I have been struggling to find a decent one with crisp text for my mac mini :(

Ответить
@harag9
@harag9 - 01.11.2023 23:18

Great video. being fairly new to react (but not dev in general), I'm still finding it confusing when you and other creators keep calling them "custom hooks" -- to me they are just functions put into a separate file. Today I created a small util "function" that I can pass an array of objects to and a column name to get back the sum of that column (e.g. cart prices for total value of cart), I'm finding it difficult calling them "useXYZ()" when to me something like calculateTotalCartValue(cartData, "price") is better.

Ответить
@danieldk5148
@danieldk5148 - 01.11.2023 18:40

Really love theses kind of videos! Thank you! One question, and sorry if it would be obvious, but I really liked the last pattern, bit how would it be implemented if I need a control state? Or that would be more like the second pattern shown?

Ответить