Answer the question
In order to leave comments, you need to log in
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
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
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question