I am calling this api inside a context provider:
const url = 'http://127.0.0.1:8000/api/posts/'
const PostListContextProvider = (props) => {
const [posts, setPosts] = useState([])
useEffect(async () => {
const {data} = await axios.get(url);
setPosts(data)
}, [posts]);
return (
<PostListContext.Provider value={ posts }>
{ props.children }
</PostListContext.Provider>
);
}
Upon consuming the context using useContext, this error occurs:
react-dom.development.js:19710 Uncaught TypeError: destroy is not a function
What am I doing wrong?
ps.even though I am getting the error, I am still successfully fetching the data