js
Properly handle unifying interfaces from tRPC call?
I have two types of objects in my database,
quests
and tasks
, which share several common properties, however they are named slightly differently (e.g. quests.startingAssessmentContent
and tasks.startingContent
), as well as a component which reads the contents of either one of these objects interchangeably.
I want to unify my interfaces for the tRPC procedure outputs for these two objects, so I made a custom hook:
What is the correct way to handle calling a function like normalizeEditorDataReturn
? Right now I get an error that quest is undefined, assuming because the data hasn't loaded yet. Not sure what is the best approach to this? Thanks for the help!2 replies