Question: ```
import React, {useState,useEffect} from 'react';
import ReactDOM from 'react-dom';
import reportWebVitals from './reportWebVitals';

function AppTwo(props){
    const [state, setState] = React.useState("initial value");
    useEffect(() => {
      console.log(`useEffect: ${state}`);
    },[state]);

    setState("updated value");

    console.log(state);
    return `<h1>${state}</h1>`;
}

ReactDOM.render(
    <>
        <AppTwo />
    </>,
  document.getElementById('root')
);

```

**Error: Too many re-renders. React limits the number of renders to prevent an infinite loop.**

Answer: 
Don't call `setState` inside of the component body. It will update every time the component re-renders. That's why you are getting an infinite loop of state updates.
WORKS!

```
import React, {useState,useEffect} from 'react';
import ReactDOM from 'react-dom';
import reportWebVitals from './reportWebVitals';

function AppTwo(props){
    const [state, setState] = React.useState("initial value");
    useEffect(() => {
      console.log(`useEffect: ${state}`);
    //   document.getElementById('btn').innerHTML = `<h1>State: ${state}</h1>`;
    },[state]);

    console.log(state);
    return (
    <>
        <h1>State: {state}</h1>
        <button id="btn" onClick={() => {setState('updated value')}}>
        click
        </button>
    </>
    )
}

ReactDOM.render(
    <>
        <AppTwo />
    </>,
  document.getElementById('root')
);

```