Dear Community
I am trying to create a react widget to read values from the object type and render as a card and loop thru the object type values and show as cards.
I tried to write the code as below
import {
isAsyncValue_Loaded,
IWorkshopContext,
} from “@osdk/workshop-iframe-custom-widget”;
import React, { useCallback, useEffect, useState } from “react”;
import { CONFIG } from “./workshop_config”;
import { myobjecttype } from “@my-react-application-view/sdk”;
import client from “./client”;
const myDraftsView: React.FC<{
loadedWorkshopContext: IWorkshopContext;
}> = ({ loadedWorkshopContext }) => {
const [mydetails, setmyDetails] = useState<myobjecttype | null>(
null
);
console.log(“Hello Before”);
const getmyDetailsObjects = useCallback(async () => {
const primaryKeys = isAsyncValue_Loaded(
loadedWorkshopContext.smd.fieldValue
)
? (loadedWorkshopContext.smd.fieldValue.value?.primaryKeys ?? [])
: [];
console.log("Hello Before try");
try {
const results = await Promise.all(
primaryKeys.map(
(pKey) => client(myobjecttype).fetchOne(pKey.toString())
)
);
console.log("Hello");
console.log(results);
setmyDetails(results);
} catch (e) {
console.error("Error fetching myobjecttype:", e);
}
}, [loadedWorkshopContext.smd.fieldValue]);
useEffect(() => {
getmyDetailsObjects();
}, [getmyDetailsObjects]);
return
};
export default SMDraftsView;
–
I am getting error at the line setmyDetails(results); as
Argument of type ‘(ObjectIdentifiers & { readonly $objectSpecifier: ObjectSpecifier; readonly $objectType: string; readonly $title: string | undefined; } & Pick<…> & {} & { …; })’ is not assignable to parameter of type ‘SetStateAction<myobjecttype | null>’.
I am not understanding what and how to fix this ?
I just want to read all the values from object type.