Jasperora commented on code in PR #53307:
URL: https://github.com/apache/airflow/pull/53307#discussion_r2206673452


##########
airflow-core/src/airflow/ui/src/pages/TaskInstance/Header.tsx:
##########
@@ -65,6 +65,10 @@ export const Header = ({
 
   const [note, setNote] = useState<string | null>(taskInstance.note);
 
+  useEffect(() => {
+    setNote(taskInstance.note ?? "");

Review Comment:
   Hi @bbovenzi, thanks for your suggestion! After some research, I understand 
the concern about overusing `useEffect`. However, since `note` is a local 
state, `useEffect` here is only for syncing it with `taskInstance.note` when 
external updates occur. It won't influence props. If we only update state in 
`onConfirm` below, the UI may show outdated data after a backend or cache 
update.
   
   As far as I know, using `useEffect` to watch `taskInstance.note` is the most 
reliable way to keep local state in sync with changing props in React. If 
there’s a better approach, I’m happy to learn!
   
   Please let me know if I’m missing something—thanks again for the feedback 
and discussion!



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to