Code Monkey home page Code Monkey logo

Comments (4)

gustavoguichard avatar gustavoguichard commented on June 21, 2024 1

Hey @mschipperheyn , this is a very specific question and would require some research.
But you can take advantage of the frontside of remix-forms if you make your backend comply the same contract as performFormAction. So you basically just need to return the same structure from back-end.

from remix-forms.

danielweinmann avatar danielweinmann commented on June 21, 2024 1

Actually, now that I read it again, I think @gustavoguichard was referring to number 3 :)

from remix-forms.

mschipperheyn avatar mschipperheyn commented on June 21, 2024

I cannot put any requirements on the backend. The backend is effectively a graphql api.

So, I would like to just send a request and process the return client side. From what you said I'm not 100% sure if I can use remix-forms purely client side, which I guess is my real question. Would I be able to customize the functionality in such a way that I can replace the component that interacts with the server through our own api and intercept the requests and responses so that it adheres to the contract with other components from remix-forms? Or would I just be better off with something like Formik or React Final Form?

from remix-forms.

danielweinmann avatar danielweinmann commented on June 21, 2024

Hey, @mschipperheyn!

  1. You can use Remix Forms purely on the client side if you use React Router 6.4+ data APIs. With them, your actions will run on the client.

  2. You can also have a Remix app as a Backend-For-Frontend that will communicate with your GraphQL backend from server to server. If that's a possibility, I think it's the best approach.

  3. You can use only the Form side of Remix Forms and never use formAction. If you pass an action prop to the form that points to a server that knows how to receive application/x-www-form-urlencoded requests, you can go nuts. Just remember that you'll have to manually return errors in the same format as formAction returns if you want to render server-side error messages. I would not recommend this approach, but it is a possibility.

  4. There is also a fourth possibility, which is what @gustavoguichard was referring to in his comment. In theory, you can use Remix Forms with any framework, as long as you:

  • Create the following components/hooks using the same interface as Remix/React Router: Form, useActionData, useSubmit, and useNavigation.
  • Create the following functions with the same interface as Remix/React Router: redirect, and json.

Remix Forms was not created to be used with other frameworks, though. This possibility is a side-effect of us making it work both with Remix and React Router in the same package. Leverage it at your risk :)

from remix-forms.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.