`In an async function, when I call setState the component doesn't get re-rendered?
V
V
ValeraNakhuy2020-01-17 14:08:23
React
ValeraNakhuy, 2020-01-17 14:08:23

In an async function, when I call setState the component doesn't get re-rendered?

verifyProjectSkill = async skill => {
    
       try {
           let result = await fetch(`/skills/verify?project_skill_id=${projectSkill.id}`);
           let project_skill_verification = await result.json();
           skill.project_skills_verifications.push(project_skill_verification);

           setSkills(projectSkills)

       }
    };

In general, when I call the useState hook, it does not render.
In general, they suggest wrapping the function in useEffect, but I need to trigger it on a button click, and why do I need useEffect in this case? How to be, help.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question