The Perfect Modal in React

Поделиться
HTML-код
  • Опубликовано: 29 ноя 2024

Комментарии • 36

  • @ifeoraokechukwu1346
    @ifeoraokechukwu1346 4 месяца назад +8

    This is a very clean and nice video. I love the animations and editing of the video and the fact that you used a UI library for the Modal.
    Your video started out very nicely - correctly exposing the pitfalls of the way modals are created and handled in React components (whether in a SPA, SSR or SSR+RSC scenario)
    However, your final solution is worse because we are creating more boilerplate due to the use case of having multiple modals for perhaps multiple components on a page.
    There by increasing the amount of coupling between the logic of modal and that of the page.
    At least you would have created a custom hook like so:
    export const useModal = (defaultOpen = false) => {
    const [isOpen, setIsOpen] = useState(defaultOpen);
    const [modalType, $setModalType] = useState(null);
    return { isOpen, modalType, setIsOpen, setModalType: (modalType: T) => {
    setIsOpen(true);
    $setModalType(modalType)
    }}
    };
    But even the above will eventually spiral out of control because to mange it minimally,
    you need a dictionary of modal types that map to modal body components like so:
    const modalBodyMap: Record = {
    "edit": EditProductModal
    };
    The video ended without you showing the Zustand way to manage all this which i believe is overkill.
    No one should require Zustand to manage just modals.
    Thankfully, i won't be following the ideas shared in this video
    As i have a superior way to manage all this.

    • @snatvb
      @snatvb 4 месяца назад +1

      totaly agree with you

    • @lamhung4899
      @lamhung4899 3 месяца назад +1

      Your snippets need extra stuffs for Modal's props. And that would be much fun with TypeScript 😊

  • @snatvb
    @snatvb 4 месяца назад +3

    trigger is much more convenient - you're essentially back to the first use of the state

    • @webster-dev
      @webster-dev 4 месяца назад

      No, use to props om single page or react

  • @ojez3628
    @ojez3628 4 месяца назад +11

    bro those animstions are crazy good

  • @serhiyi7526
    @serhiyi7526 4 месяца назад +1

    when I saw zustan, I thought "oh, finally a good solution for modal windows" ( by using global state management ), and then something went wrong. It's a terrible decision because of the useState. Since the problems described earlier were not solved. It is better to create a custom hook that will be responsible for displaying the modal

  • @Pete133
    @Pete133 3 месяца назад

    Right before you showed zustand I was thinking, “this is where I love to use zustand”. It’s so much easier than react state and context or prop drilling. Haha cheers!

  • @snatvb
    @snatvb 4 месяца назад +1

    excuse me, what do you use for video animations? motioncanvas? if yes, could you hint how did you create hirarchy(tree) animation?

  • @ahsanmughal3806
    @ahsanmughal3806 3 месяца назад

    Amazing. I learn something new ❤

  • @valostudent6074
    @valostudent6074 4 месяца назад

    Bro your video are so in depth and so beautifully presented, I am a big fan just watching this video....big fan big fan big fan bro keep it up you are the best

    • @PixelDeveloper
      @PixelDeveloper  4 месяца назад

      Thank you for the kind of your words 😁

  • @raves_r3177
    @raves_r3177 4 месяца назад

    just use zustand and render the modal only once on the very root of the application.

    • @kapiqu2709
      @kapiqu2709 3 месяца назад

      And You finish with so many unused code loaded with every page. Look at First Load JS and page insights

  • @_AshishMohanty
    @_AshishMohanty 4 месяца назад +1

    bro which software or website u use to create this animation?

  • @nikhilkr_yt
    @nikhilkr_yt 4 месяца назад

    yo xccurate! switching career?
    didn't know you could code.
    Amazing tutorial dude!🔥

  • @aufarijaal
    @aufarijaal 4 месяца назад

    bro is comeback after 2 years as a different "person". mantap

  • @aiyn470
    @aiyn470 3 месяца назад

    As new dev using react i already learn this by an Accident 😅😅😅

  • @inderjotsingh5868
    @inderjotsingh5868 4 месяца назад

    I don't know , how this happened , yesterday I was searchearing for same on Claude , but didn't got a convincing answer , and today our video was recommended to me .

  • @ikmalilbirri8895
    @ikmalilbirri8895 4 месяца назад

    🤔Then how to pass the selected data to the modal. Add useState again?

  • @sudoalex
    @sudoalex 4 месяца назад

    What's that IDE? Looks nice

    • @PixelDeveloper
      @PixelDeveloper  4 месяца назад +1

      I'm using nvim for my code editor

    • @sudoalex
      @sudoalex 4 месяца назад +1

      @@PixelDeveloper nice setup you should make a video about that 😆

  • @zaimcodes
    @zaimcodes 4 месяца назад

    Mantap!

  • @ariesrabbit
    @ariesrabbit 3 месяца назад

    need your icon extension name 😂

    • @PixelDeveloper
      @PixelDeveloper  3 месяца назад

      In Neovim, icons are not displayed through an extension because Neovim runs in the terminal. Instead, it uses a specific font family to render icons. The font I use is Nerd Font JetBrains Mono.

    • @ariesrabbit
      @ariesrabbit 3 месяца назад

      @@PixelDeveloper tks alot, that just so cool bro, keep ur fire 🔥

  • @saiphaneeshk.h.5482
    @saiphaneeshk.h.5482 4 месяца назад +1

    Nice

  • @indofiz1077
    @indofiz1077 4 месяца назад

    Are you indonesian?

  • @RutsuKun
    @RutsuKun 4 месяца назад

    Redux or React Context

  • @mohamedbinothman984
    @mohamedbinothman984 3 месяца назад

    wasting of time

  • @AdolfRizzler41
    @AdolfRizzler41 4 месяца назад

    Which Library is best for modals and notifications ?