I am trying to use useMemo like useEffect with componentDidMount behaviour but my useMemo is acting just like componentWillMount and is rendering unstoppably .
Here is the code:
useMemo(() => {
console.log('rendered');
fetch(`backend url`, {
method: 'PUT',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
userId: userInf._id,
fields: ['readers', 'followers', 'news', 'podcast', 'video'],
}),
})
.then((res) => res.json())
.then((res) => {
setUserArticles(res.news);
})
.catch((err) => err);
}, [userArticles]);
Any suggestions please?