Skip to content

Commit

Permalink
minor cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
phryneas committed Oct 10, 2024
1 parent 35b08a8 commit 036fbc0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { createRenderStream } from "./renderStream/createRenderStream.js";
import type { NextRenderOptions } from "./renderStream/createRenderStream.js";

import { Render } from "./renderStream/Render.js";
import { createElement } from "react";
import { createElement } from "rehackt";
import { Assertable, assertableSymbol, markAssertable } from "./assertable.js";

export interface SnapshotStream<Snapshot, Props> extends Assertable {
Expand Down
17 changes: 7 additions & 10 deletions src/renderStream/createRenderStream.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -221,15 +221,12 @@ export function createRenderStream<Snapshot extends ValidSnapshot = void>({
return baseRender(ui, {
...options,
wrapper: (props) => {
let elem: React.ReactNode = React.createElement(
Wrapper,
undefined,
props.children
const ParentWrapper = options?.wrapper || React.Fragment;
return (
<ParentWrapper>
<Wrapper>{props.children}</Wrapper>
</ParentWrapper>
);
if (options?.wrapper) {
elem = React.createElement(options.wrapper, undefined, elem);
}
return elem;
},
});
}) as typeof baseRender;
Expand Down Expand Up @@ -358,15 +355,15 @@ export function useTrackRenders({ name }: { name?: string } = {}) {

if (!component) {
throw new Error(
"useTrackRender: Unable to determine component. Please ensure the hook is called inside a rendered component or provide a `name` option."
"useTrackRenders: Unable to determine component. Please ensure the hook is called inside a rendered component or provide a `name` option."
);
}

const ctx = useRenderStreamContext();

if (!ctx) {
throw new Error(
"useTrackComponentRender: A Render Stream must be created and rendered to track component renders"
"useTrackRenders: A Render Stream must be created and rendered to track component renders"
);
}

Expand Down

0 comments on commit 036fbc0

Please sign in to comment.