Remix.run Can Be Highly Interactive: useFetcher + Zod

Поділитися
Вставка
  • Опубліковано 28 гру 2024

КОМЕНТАРІ • 18

  • @sjc5
    @sjc5  Рік тому +3

    UPDATE: An evolved version of this pattern has now been published to npm as an easily consumable toolkit: github.com/sjc5/remix-easy-mode#readme

  • @JonathanHigger
    @JonathanHigger Рік тому +1

    This seems like a good pattern, I may use this on my app

    • @sjc5
      @sjc5  Рік тому

      Good timing, now available as a package! github.com/sjc5/remix-easy-mode#readme

  • @mailok
    @mailok Рік тому +1

    This is great!

  • @eleah2665
    @eleah2665 10 місяців тому

    Cool. Thanks.

  • @kyuss789
    @kyuss789 Рік тому +1

    Won’t passing the actual action to your custom hook force it to be bundled in the frontend code? Which would be you would include and other back end code in your front end like the prisma client for example?
    Would it be better to just pass the action type as a generic to the function?

    • @sjc5
      @sjc5  Рік тому

      Excellent point. It really should just be a generic.

    • @joelalexander7293
      @joelalexander7293 Рік тому +2

      @@sjc5 Any plan to update the repo to reflect this change? I am still new to typescript and remix, so i conceptually understand the above, but not sure what the follow on changes would be if instead of the action itself, you only had a action_type.

    • @sjc5
      @sjc5  Рік тому +2

      @@joelalexander7293 Yeah good idea, should do a follow-up on this and get the repo updated.

    • @sjc5
      @sjc5  Рік тому +2

      @@joelalexander7293 Now available as a package, of course addressing this concern :) github.com/sjc5/remix-easy-mode#readme

    • @joelalexander7293
      @joelalexander7293 Рік тому +1

      @@sjc5 awesome, thanks!

  • @marqetintl
    @marqetintl Рік тому

    Question: What would the advantages of this be compared to simply re-exporting the action from the api route, which i am currently doing?

  • @SeanLazer
    @SeanLazer Рік тому +1

    Really cool, but wondering if there's a reason to choose this stack vs. just going with create-t3-app in the first place?

    • @sjc5
      @sjc5  Рік тому +2

      Thanks! Put simply, the SSR story isn't nearly as nice with create-t3-app as with Remix. It's totally possible to SSR, but you have to build these SSG helpers to do it in a nice way, and it's just not even close to as nice as Remix's built-in loader pattern IMO.
      Also, you can export hooks from Remix resource routes -- you can't export hooks from NextJS server-side files! That alone makes Remix a better DX.

    • @SeanLazer
      @SeanLazer Рік тому +1

      @@sjc5 Awesome. So do you use this approach for data loading/mutating in conjunction with Remix's loaders/actions for other data?

    • @sjc5
      @sjc5  Рік тому +1

      @@SeanLazer I think in most cases for data loading, you’ll want to use standard route-level loaders. Otherwise you’re reintroducing spinners. Similarly, for mutations involving a page transition, the standard Remix action pattern makes sense. This is more just a helper around useFetcher to make building those “same page mutation” APIs really painless.