E
E
Elena2020-11-27 22:26:42
React
Elena, 2020-11-27 22:26:42

Why doesn't the 'title' property exist for the 'Faq[]' type?

Tell me, it’s not clear why there are no title and content properties in my Faq[] type. I wrote them in the Faq[] type
export const FaqCards = () => {
const { id } = useParams();
console.log(id)
const [currentFaqs, setCurrentFaqs] = useState();
const classes = useStyles();
useEffect(() => {
(async () => {
try {
const faqsId = await HttpService.get(`/faqs/${id}`);
setCurrentFaqs(faqsId);
} catch (error) {}
})( );
},[id]);

if(currentFaqs === null) return null;
else {
return (






{faqs.title}
{faqs.content}






);
};
};

Answer the question

In order to leave comments, you need to log in

2 answer(s)
E
Evgeny Shcherbakov, 2020-11-27
@lisichka30

As I understood, there were several problems, judging by the provided code.
1. There was no type/interface for Faq
2. Wrong variable faqs was used, currentFaqs should have been taken instead

A
abberati, 2020-11-28
@abberati

Faq[] is an array of objects of type Faq. The array does not have a title field.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question