英文:
Remix Form sends Get request after post request
问题
我在我的remixjs代码中遇到了问题。
当我尝试使用Remixjs中的Form发送POST请求时,它发送了一个POST请求,然后发送了一个GET请求,Form组件是Remix js中的预定义组件,它应该阻止默认行为。
我不知道为什么?以及如何修复这个问题?
英文:
I have a problem in my remixjs code
When I try to send a post request using Form in remixjs it sends a POST and after that a Get request , the Form component is a pre defined component in remix js and it should preventDefault
I don't know why ? and how to fix this ?
答案1
得分: 1
通常,使用表单时,您的用户很可能会在服务器上更改数据。当执行操作时,Remix通过运行该路由的所有加载器来重新验证您的数据。这样做是为了确保您的用户界面与您的数据同步。
这也是在使用常规表单时您的浏览器所做的事情。它将数据发送到服务器,然后获取包含新数据的新文档。Remix是建立在这样的Web标准之上的。掌握Remix,掌握Web 😄。
英文:
Usually with a form, your users are most likely mutating data on the server. Remix revalidates your data by running all the loaders for that route when an action is performed. This is done so your UI is sync with your data.
This is also what your browser does when you use a regular form. It posts to the server and a new document is fetched with fresh data. Remix is built upon such Web Standards. Get good at Remix, get good at the web 😄.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论