I have this crowded form with some 30-40 fields, and most of them have kinda complex logic. Understandibly I wanted to make these form areas reusable for both create and edit pages since both are identical in terms of form items and fields. I got them to work without much effort, and they work fine for most parts, except the quest for reusability introduced some other challenges and now I am questioning if it's worth it.
For me some of the challenges of using the same forms for both create and edit are:
Conditionals everywhere. Want to make a field uneditable in edit mode? Extra props to pass in and disable said fields with those props.
Edit mode needs initial state so forms fields are filled in with existing data but create page does not like that, so even more and even worse conditions like:
const { user } = React.useContext(DetailContext) ?? {}; // I know...
const [userType, setUserType] = useState(user?.user_type ?? null); // yep
At this point I can't even decide how to safely assign and use stuff, and I can't estimate what parts are prone to breaking.
Is this inevitable and fine as is or is this complete silliness? What are some good practices for making form areas or forms reusable? Can I reduce noise without sacrificing reusability?