Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Good people can someone please help on the following error I am new to Forge

Bongani Gumede September 16, 2021

Validation error

Expected direct child of CustomField to be one of [Avatar, AvatarStack, Code, Image, Text, Tooltip, Tag, TagGroup]. Received String component.
Expected direct child of CustomField to be one of [Avatar, AvatarStack, Code, Image, Text, Tooltip, Tag, TagGroup]. Received String component.
String must be used within one of [Text, Heading].
String must be used within one of [Text, Heading].

1 answer

0 votes
Bongani Gumede September 16, 2021
import ForgeUI, { CustomFieldCustomFieldEditrenderTextTextFielduseProductContext,StatusLozenge,useState } from "@forge/ui";
import api,{routefrom "@forge/api";

const fetchIssue = async (issuekey=>{
  console.log(issuekey);
const response = await api.asUser().requestJira(route`/rest/api/3/issue/${issuekey}`,
 {headers: {'Accept': 'application/json'}});
console.log(`Response: ${response.status} ${response.statusText}`);
console.log(await response.json());
return await response.json();
}
const View = () => {
 
  const context = useProductContext();
  console.log (`${JSON.stringify(context)}`);
  const [issue,setIssue] = useState (async () =>  await fetchIssue(context.platformContext.issueKey));
  
  const { extensionContext: {fieldValue }} = useProductContext();  
  return (<CustomField> {issue?.customfield_10331 ? (<Text> {JSON.stringify(issue)}</Text>):<Text>Loading...</Text>} </CustomField>);
 
};
// const Edit = () => {
//   const onSubmit = values => {
//       return values.text
//   };

//   return (
//     <CustomFieldEdit onSubmit={onSubmit}>
//       <TextField name="text" label="Say hello to:"></TextField>
//     </ CustomFieldEdit>
//   );
// }
export const runView = render(<View/>);
//export const runEdit = render(<Edit/>)

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
FREE
TAGS
AUG Leaders

Atlassian Community Events