I am trying to use hooks, but am in an infinite loop. The code is below. fetchSomeData and uuid get passed in from the parent component. The data that is fetched is the same every time. Thanks.
import React, { useState } from 'react';
const MyComponent = (props) => {
const [myList, setMyList] = useState([]);
const {fetchSomeData, uuid} = props;
fetchSomeData(uuid)
.then( (response) => {
setMyList(response.payload.data.activities);
})
const renderItem = (item)=>{
return (<div>{item.title}</div>)
}
return (
<div> My COmponent
<div>
{myList.map (renderItem)}
</div>
</div>
)
}
export default MyComponent