Utilizing Gatsby along with Typescript, I have been working on developing a blog that is powered by Contentful CMS.
In the process, I have created a FeaturedPost
component that I intend to showcase on the main page, and here is the implementation:
FeaturedPost.tsx
interface IProps {
data: {
contentfulPost: ContentfulPost;
};
}
const FeaturedPost: React.FunctionComponent<IProps> = ({ data }) => {
const { title, description } = data.contentfulPost;
return (
<>
<Header>{title}</Header>;
<div>{description}</div>
</>
);
};
export const query = graphql`
query featuredPost($slug: String) {
contentfulPost(slug: { eq: $slug }) {
title
slug
description {
childMarkdownRemark {
html
}
}
}
}
`;
export default FeaturedPost;
This snippet displays my index page code:
index.tsx
const IndexPage: React.FunctionComponent<P> = () => {
return (
<Layout>
<SEO
title="Home"
keywords={[`gatsby`, `application`, `react`]}
description="Index for something I can't remember?!"
/>
<FeaturedPost />
<h1>Hi people</h1>
<p>Welcome to your new Gatsby site.</p>
<p>Now go build something great.</p>
<div style={{ maxWidth: `300px`, marginBottom: `1.45rem` }} />
</Layout>
);
};
export default IndexPage;
Tslint is currently expecting me to pass a prop named data
to the FeaturedPost
component due to the implementation of interface IProps
, even though there is no actual data
being passed.
The FeaturedPost
component retrieves this data as a response from the query it sends. Any suggestions on what might be causing this issue or how I could address it to satisfy the linter?