Cześć,
uczę się TS, wyskoczył mi błąd o treści jak w tytule i nie wiem jak to naprawić ;( wkleję poniżej kod, jeśli ktoś wie to proszę o pomoc. Nie ważne czy dam jako typ newPost: newPostInterface czy nie bo ten błąd i tak występuje.
import React, { useState } from "react";
export const PostsContext = React.createContext({
posts: [],
handleAddPost: () => {},
handleDeletePost: () => {},
});
interface PostsProviderProps {
children: any;
}
interface newPostInterface {
username: string;
content: string;
image: any;
}
const PostsProvider = ({ children }: PostsProviderProps) => {
const [posts, setPosts] = useState([]);
const handleAddPost = (values: any, selectedFile: any) => {
const newPost = {
username: values.username,
content: values.content,
image: selectedFile,
};
setPosts([newPost, ...posts]);
};
};