Skip to content

Commit

Permalink
Review code
Browse files Browse the repository at this point in the history
  • Loading branch information
tbragaf committed Feb 16, 2024
1 parent 7e0bce8 commit 4e82ffa
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 10 deletions.
3 changes: 2 additions & 1 deletion ReactViewResources/Loader/Internal/ComponentsRenderCache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,9 @@ export function storeViewRenderInCache(view: ViewMetadata, cacheEntry: IRenderCa
// cache view html for further use
const elementHtml = view.root!.innerHTML;
// get all stylesheets except the sticky ones (which will be loaded by the time the html gets rendered) otherwise we could be loading them twice

const stylesheets = getStylesheets(view.root!).filter(l => l.dataset.sticky !== "true").map(l => l.outerHTML).join("");

// the remaining code can be executed afterwards
return new Promise<void>(() => {
// insert rendered html into the cache
Expand Down
3 changes: 2 additions & 1 deletion ReactViewResources/Loader/Internal/ViewPortal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export type ViewLifecycleEventHandler = (view: ViewMetadata) => void;
export type ViewErrorHandler = (view: ViewMetadata, error: Error) => void;

export interface IViewPortalProps {
view: ViewMetadata
view: ViewMetadata;
viewMounted: ViewLifecycleEventHandler;
viewUnmounted: ViewLifecycleEventHandler;
viewErrorRaised: ViewErrorHandler;
Expand Down Expand Up @@ -56,6 +56,7 @@ export class ViewPortal extends React.Component<IViewPortalProps, IViewPortalSta

public componentDidMount() {
const styleResets = document.createElement("style");
styleResets.media = "text/css";
styleResets.innerHTML = ":host { all: initial; display: block; }";

this.shadowRoot.appendChild(styleResets);
Expand Down
9 changes: 2 additions & 7 deletions ReactViewResources/Loader/Internal/ViewPortalsCollection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,7 @@ export class ViewPortalsCollection extends React.Component<IViewPortalsCollectio
);
}

public render(): JSX.Element | null {
return (
<>
{this.props.views.items.sort((a, b) => a.name.localeCompare(b.name))
.map(view => this.renderViewPortal(view))}
</>
);
public render(): React.ReactNode {
return this.props.views.items.sort((a, b) => a.name.localeCompare(b.name)).map(view => this.renderViewPortal(view));
}
}
2 changes: 1 addition & 1 deletion Sample.Avalonia/ExtendedReactViewFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public override IViewModule[] InitializePlugins() {
return new IViewModule[] { viewPlugin };
}

public override bool ShowDeveloperTools => false;
public override bool ShowDeveloperTools => true;

public override bool EnableViewPreload => true;

Expand Down

0 comments on commit 4e82ffa

Please sign in to comment.