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

0

81
Views
What pattern should I use in a React form that needs an item ID when submitting?

I have a web app that requires some crud functionality. In this specific case, the user needs to update an existing item in a database. Right now I have a form component that I tried to keep as "dumb" as possible, however, now I am not so sure if it is as "dumb" as it could be while still sticking to good React patterns.

I am passing in 3 props to my form:

  1. Existing values which I then set in state as the inputs are controlled
  2. ID of the item that user is updating
  3. Function called "onSubmit" which is essentially an API call to my database. It requires updated values and an ID as arguments

On form submit, I call my "onSubmit" function that has been passed in via props, which takes in the ID I have also passed in via props as well as the new values the user has selected via the inputs on the form.

Is this the common pattern to use in this situation?

almost 3 years ago · Juan Pablo Isaza
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