jadami10 commented on code in PR #14736:
URL: https://github.com/apache/pinot/pull/14736#discussion_r1902008220
##########
pinot-controller/src/main/resources/app/pages/TenantDetails.tsx:
##########
@@ -152,6 +152,18 @@ const TenantPageDetails = ({ match }:
RouteComponentProps<Props>) => {
const [showRebalanceServerModal, setShowRebalanceServerModal] =
useState(false);
const [schemaJSONFormat, setSchemaJSONFormat] = useState(false);
+ // This is quite hacky, but it's the only way to get this to work with the
dialog.
+ // The useState variables are simply for the dialog box to know what to
render in
+ // the checkbox fields. The actual state of the checkboxes is stored in the
refs.
+ // The refs are then used to determine how we delete the table. If you try
to use
+ // the state variables in this class, you will not be able to get their
latest values.
+ const [dialogCheckboxes, setDialogCheckboxes] = useState({
+ deleteImmediately: false,
+ deleteSchema: false
+ });
+ const deleteImmediatelyRef = useRef(false);
+ const deleteSchemaRef = useRef(false);
+
Review Comment:
I don't know react well enough, but I spent days on this with a coworker as
well as multiple LLM tools, and this is the only thing that reliably worked. I
think the issue is the very strange lifecycle of state variables and functions.
- "show dialog" state variable is in TenantDetails
- checkbox definition is in TenantDetails
- checkbox state is in TenantDetails
- the actual modal is in Confirm
- the children are rendered in Confirm
- the callbacks are defined in TenantDetails but activated in Confirm
Reusing the state variables from TenantDetails and rendering them in
Confirm, I only got 2 bad things working
- the checkbox updates, but the callback doesn't see the latest value until
the second time it's called
- the callback sees the latest value, but the checkbox doesn't actually
visually update
This leads me to believe that the way we're creating + rendering the modal
does not allow for a single state variable to work since there's no possible
update order for every component to do the right thing.
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]