• Jobs
  • About Us
  • professionals
    • Home
    • Jobs
    • Courses and challenges
  • business
    • Home
    • Post vacancy
    • Our process
    • Pricing
    • Assessments
    • Payroll
    • Blog
    • Sales
    • Salary Calculator

0

201
Views
Manejo de la acción en Remix.run sin POST

Leí los documentos de Remix sobre la acción y la mayor parte de la información que puedo encontrar sobre la acción es que usa el formulario POST con el botón Enviar para activar la acción.

 export default function Game() { const counter = useLoaderData(); return ( <> <div>{counter}</div> <div> <Form method="post"> <button type="submit">click</button> </Form> </div> </> ); }

Sin embargo, ¿cómo se activaría la acción con respecto a otra cosa como... arrastrar y soltar componentes, donde después de soltarlos debería activar la publicación de acción?

about 3 years ago · Juan Pablo Isaza
1 answers
Answer question

0

useSubmit debería hacer lo que quieras.

Aquí hay un ejemplo de los documentos

 import { useSubmit, useTransition } from "remix"; export async function loader() { await getUserPreferences(); } export async function action({ request }) { await updatePreferences(await request.formData()); return redirect("/prefs"); } function UserPreferences() { const submit = useSubmit(); const transition = useTransition(); function handleChange(event) { submit(event.currentTarget, { replace: true }); } return ( <Form method="post" onChange={handleChange}> <label> <input type="checkbox" name="darkMode" value="on" />{" "} Dark Mode </label> {transition.state === "submitting" ? ( <p>Saving...</p> ) : null} </Form> ); }
about 3 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Our process Sales
Legal
Terms and conditions Privacy policy
© 2025 PeakU Inc. All Rights Reserved.

Andres GPT

Recommend me some offers
I have an error