Я пытаюсь использовать React Hooks, но каким-то образом мое состояние не обновляется
const [Choices, setChoices] = useState([]);
useEffect(() => {
async function getUsers() {
// Here’s the magic
let tempChoices = [];
const promises = MAINLIST.List.ChoicesFields.map(async z => {
tempChoices[z] = [];
let GetChoicesFromInternalFieldResults = await GetChoicesFromInternalField(
z
);
GetChoicesFromInternalFieldResults.map(c => {
tempChoices[z].push({
key: c,
text: c,
value: c
});
});
});
await Promise.all(promises);
const object = { Choices: tempChoices };
// THIS IS PRINTING CORRECT VALUES
console.log(object);
setChoices(object);
}
getUsers();
}, []);
Вот результат console.log
![enter image description here](https://i.stack.imgur.com/RDt0c.png)
но когда я проверяю состояние в инструменте разработчика, состояние пусто
![enter image description here](https://i.stack.imgur.com/7MqeX.png)