Skip to content
Advertisement

While creating item from parent to child component, going to infinite loop in React

This is my home page and getting list data then creating List component as much as need. Then going to List component and creating list item. so creating new component using map function. I tried different ways for it but I can’t figure out. It goes infinite loop whatever I did.

Home.jsx

JavaScript

in List component, creating List item component as much as need.

List.jsx

JavaScript

last component here.

ListItem.jsx

JavaScript

Advertisement

Answer

Try to remove the useEffect from the List component and map on the list.content directly:

JavaScript
User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement