Skip to content

Commit cd04698

Browse files
use validateComponent function instead of manually validating it
1 parent 6307c6e commit cd04698

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
@@ -205,17 +205,13 @@ const stringToStream = (str: string): Readable => {
205205
};
206206

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

210210
let renderResult: null | Readable = null;
211211

212212
try {
213-
const componentObj = ComponentRegistry.get(name);
214-
if (componentObj.isRenderer) {
215-
throw new Error(`\
216-
Detected a renderer while server rendering component '${name}'. \
217-
See https://github.com/shakacode/react_on_rails#renderer-functions`);
218-
}
213+
const componentObj = ComponentRegistry.get(componentName);
214+
validateComponent(componentObj, componentName);
219215

220216
const reactRenderingResult = createReactOutput({
221217
componentObj,
@@ -242,7 +238,7 @@ See https://github.com/shakacode/react_on_rails#renderer-functions`);
242238

243239
renderResult = stringToStream(handleError({
244240
e,
245-
name,
241+
name: componentName,
246242
serverSide: true,
247243
}));
248244
}

0 commit comments

Comments
 (0)