Skip to content

Commit

Permalink
fix: update useEffect, avoid agentUpdates dependency
Browse files Browse the repository at this point in the history
Update Agent.tsx
  • Loading branch information
ivyjeong13 committed Nov 26, 2024
1 parent 475d953 commit f49a6eb
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions ui/admin/app/components/agent/Agent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,16 @@ export function Agent({ className, onRefresh }: AgentProps) {
const [agentUpdates, setAgentUpdates] = useState(agent);

useEffect(() => {
if (agent.id === agentUpdates.id) {
setAgentUpdates({
...agentUpdates,
aliasAssigned: agent.aliasAssigned ?? false,
});
}
setAgentUpdates((prev) => {
if (agent.id === prev.id) {
return {
...prev,
aliasAssigned: agent.aliasAssigned ?? false,
};
}

return agent;
});
}, [agent]);

const partialSetAgent = useCallback(
Expand Down

0 comments on commit f49a6eb

Please sign in to comment.