this is the state of the component:
class Feed extends Component<FeedProps, FeedState> {
constructor(props) {
super(props);
this.state = {
isEditing: false,
posts: [],
totalPosts: 0,
editPost: null,
status: "",
postPage: 1,
postsLoading: true,
editLoading: false,
};
}
return (jsx code here)}
this is the interface that I wrote:
interface FeedState {
isEditing: boolean;
posts: typeof Post[];
totalPosts: 0;
editPost: null | boolean;
status: string;
postPage: 1;
postsLoading: boolean;
editLoading: boolean;
}
i need to set default value for totalPosts and postpage but I could not figure out. Also
posts: typeof Post[]; // Post is a functional component and i try to say posts is gonna be array of Post instances. is it correct or shall I convert Post to class component.
I am getting these errors:
Types of property 'totalPosts' are incompatible.
Type 'number' is not assignable to type '0'.
Type '{ posts: React.FC<PostProps>[]; totalPosts: number; }' is not assignable to type 'FeedState | Pick<FeedState, "posts" | "totalPosts">'.
I am in the middle of converting my js project to tsx and i cannot run the code yet.