JavaScript react useEffect is running and fetching data none stop react useeffect running twice,react useeffect run once,react useeffect

I have a simple react component that uses react hooks. I'm using useEffect and useState.
The problem is that i realized my API is getting huge amount of hits, after debugging i see that useEffect is running none stop!

This is my very simple code:

function DisplayUser({userId}) {
  const [loggedUser, setLoggedUser] = React.useState(null);
  React.useEffect(() => {
    fetchData(userId).then(user => {
      setLoggedUser(user);
    })
  });
  return (
    <div>
      <div>{loggedUser}</div>
    </div>
  );
}
Answer:1

I just noticed an odd cookie policy problem that only affects IE. I could only test on IE11. Perhaps you know a workaround? Step 1. This requires 2 domains. We'll call them cart.com and tracking.com. ...

I just noticed an odd cookie policy problem that only affects IE. I could only test on IE11. Perhaps you know a workaround? Step 1. This requires 2 domains. We'll call them cart.com and tracking.com. ...

WHAT I WANT TO BUILD: I have such stuff in mongo: { team1: 'Love', team2: 'Popa', score: 3 } { team1: 'Love' team2: 'Ola' score: 1 } { team1: 'Popa' team2: 'Ola' score: 5 } { ...

WHAT I WANT TO BUILD: I have such stuff in mongo: { team1: 'Love', team2: 'Popa', score: 3 } { team1: 'Love' team2: 'Ola' score: 1 } { team1: 'Popa' team2: 'Ola' score: 5 } { ...

  1. mongodb simple find query
  2. mongodb tutorial find
  3. mongodb findone tutorial

AppFunction.js export default function myFunction() { var str1 = "Hello "; var str2 = "world!"; var res = str1.concat(str2); document.getElementById("demo").innerHTML = res; } App.js import ...

AppFunction.js export default function myFunction() { var str1 = "Hello "; var str2 = "world!"; var res = str1.concat(str2); document.getElementById("demo").innerHTML = res; } App.js import ...

  1. import function from file reactjs
  2. reactjs import function from another file

I am trying to create a dropdown menu with Bootstrap, with images and a long text, that may have to be word-wrapped to be inside a width of 500px I tried suggestions like this: .dropdown-menu { ...

I am trying to create a dropdown menu with Bootstrap, with images and a long text, that may have to be word-wrapped to be inside a width of 500px I tried suggestions like this: .dropdown-menu { ...

  1. bootstrap dropdown menu not working
  2. bootstrap dropdown menu on hover
  3. bootstrap dropdown menu example
  4. bootstrap dropdown menu width
  5. bootstrap dropdown menu position
  6. bootstrap dropdown menu navbar
  7. bootstrap dropdown menu scrollable
  8. bootstrap dropdown menu color
  9. bootstrap dropdown menu submenu
  10. bootstrap dropdown menu right
  11. bootstrap dropdown menu not showing
  12. bootstrap dropdown menu icon
  13. bootstrap dropdown menu select
  14. bootstrap dropdown menu off screen
  15. bootstrap dropdown menu form
  16. bootstrap dropdown menu checkbox
  17. bootstrap dropdown menu full width
  18. bootstrap dropdown menu react
  19. bootstrap dropdown menu left
  20. bootstrap dropdown menu events