bobbai00 commented on code in PR #9472:
URL: https://github.com/apache/texera/pull/9472#discussion_r4619429178
##########
frontend/.eslintrc.json:
##########
@@ -20,7 +20,7 @@
"ignorePatterns": ["projects/**/*"],
"overrides": [
{
- "files": ["*.ts"],
+ "files": ["*.ts", "*.tsx"],
Review Comment:
**Advisory:**
TSX is now linted and formatted, but test discovery still matches only `.ts`
specs (`angular.json:103` and `:118`). The unit-test builder globs those
patterns as written, so a React spec named `*.spec.tsx` would never run and CI
would stay green. I'd add the `.tsx` forms to both targets' include and exclude
lists now. The spec-only override at line 111 of this file and the Codecov
ignore at `codecov.yml:51` need the same.
##########
frontend/src/react/testing/react-host.browser.spec.ts:
##########
@@ -0,0 +1,57 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import { AfterViewInit, Component, ElementRef, OnDestroy, viewChild } from
"@angular/core";
+import { TestBed } from "@angular/core/testing";
+import { createElement } from "react";
+import { createRoot, type Root } from "react-dom/client";
+import { ReactCounter } from "./react-counter.fixture";
+
+@Component({
+ template: `<span>Angular host</span>
+ <div #container></div>`,
+})
+class ReactHostComponent implements AfterViewInit, OnDestroy {
+ private readonly container =
viewChild.required<ElementRef<HTMLElement>>("container");
+ private root?: Root;
+
+ ngAfterViewInit(): void {
+ this.root = createRoot(this.container().nativeElement);
Review Comment:
**Advisory:**
Should this host create the root outside Angular's zone? `createRoot`
attaches React's listeners for every event type, and here it runs inside the
Angular zone. Under the app's zone change detection (`main.ts:32`), each click,
pointer move or scroll in a React subtree then runs a full change-detection
pass. The JointJS and Monaco hosts live with that, but #9387 puts a host like
this under every ported component. I'd wrap `createRoot`/`render` in
`NgZone.runOutsideAngular`, as `read-only-card.directive.ts:172` does, and
re-enter with `zone.run` for callbacks into Angular.
--
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]