Skip to content

Commit 809322c

Browse files
use validateComponent function instead of manually validating it
1 parent 096231d commit 809322c

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

node_package/src/serverRenderReactComponent.ts

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -201,17 +201,13 @@ const stringToStream = (str: string): Readable => {
201201
};
202202

203203
export const streamServerRenderedReactComponent = (options: RenderParams): Readable => {
204-
const { name, domNodeId, trace, props, railsContext, throwJsErrors } = options;
204+
const { name: componentName, domNodeId, trace, props, railsContext, throwJsErrors } = options;
205205

206206
let renderResult: null | Readable = null;
207207

208208
try {
209-
const componentObj = ComponentRegistry.get(name);
210-
if (componentObj.isRenderer) {
211-
throw new Error(`\
212-
Detected a renderer while server rendering component '${name}'. \
213-
See https://github.com/shakacode/react_on_rails#renderer-functions`);
214-
}
209+
const componentObj = ComponentRegistry.get(componentName);
210+
validateComponent(componentObj, componentName);
215211

216212
const reactRenderingResult = createReactOutput({
217213
componentObj,
@@ -238,7 +234,7 @@ See https://github.com/shakacode/react_on_rails#renderer-functions`);
238234

239235
renderResult = stringToStream(handleError({
240236
e,
241-
name,
237+
name: componentName,
242238
serverSide: true,
243239
}));
244240
}

0 commit comments

Comments
 (0)