最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - index.js:1 Warning: State updates from the useState() and useReducer() Hooks don't support the second callb

programmeradmin0浏览0评论

index.js:1 Warning: State updates from the useState() and useReducer() Hooks don't support the second callback argument. To execute a side effect after rendering, declare it in the ponent body with useEffect().

const logon = async (email, password) => {
  setValores({
    email: email,
    password: password
  }, () => {
    document.getElementById('loginSubmit').click();
  });
};

index.js:1 Warning: State updates from the useState() and useReducer() Hooks don't support the second callback argument. To execute a side effect after rendering, declare it in the ponent body with useEffect().

const logon = async (email, password) => {
  setValores({
    email: email,
    password: password
  }, () => {
    document.getElementById('loginSubmit').click();
  });
};
Share Improve this question edited Jun 15, 2021 at 14:12 Dane Brouwer 2,9621 gold badge24 silver badges31 bronze badges asked Apr 23, 2020 at 10:18 LeudyLeudy 171 silver badge1 bronze badge 1
  • Can you edit your code and describe the problem and what you are trying to do! This topic may help you :) stackoverflow./help/how-to-ask – Dhia Djobbi Commented Apr 23, 2020 at 10:22
Add a ment  | 

1 Answer 1

Reset to default 5

Wele to Stack Overflow!

Please, when you post a question, make it an actual question. Post the code you tried to run, with some information on what the expected oute is. Read more about it here.

As for your problem, useState doesn't accept a callback as a parameter. If you want to perform an action after valores has changed, you can use useEffect in the ponent's body:

useEffect(() => {
  if (valores) {
    document.getElementById('loginSubmit').click();
  }
}, [valores])

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论