Warning: Cannot update a component from inside the function body of a different component.

Why is this no longer acceptable in SDK 39?

const [MyId, setMyId] = useState("");

function gettheid (responseJson) {
setMyId(responseJson);
}

It generates the following error:

Warning: Cannot update a component from inside the function body of a different component.

Does it mean that I can no longer update a useState within a function? I’m confused.

After investigating the issue, I found that the error came from a new warning introduced in React 16.13.0