Skip to content

Commit 29e7943

Browse files
use validateComponent function instead of manually validating it
1 parent 28fe2b8 commit 29e7943

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

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

194194
let renderResult: null | Readable = null;
195195

196196
try {
197-
const componentObj = ComponentRegistry.get(name);
198-
if (componentObj.isRenderer) {
199-
throw new Error(`\
200-
Detected a renderer while server rendering component '${name}'. \
201-
See https://github.com/shakacode/react_on_rails#renderer-functions`);
202-
}
197+
const componentObj = ComponentRegistry.get(componentName);
198+
validateComponent(componentObj, componentName);
203199

204200
const reactRenderingResult = createReactOutput({
205201
componentObj,
@@ -226,7 +222,7 @@ See https://github.com/shakacode/react_on_rails#renderer-functions`);
226222

227223
renderResult = stringToStream(handleError({
228224
e,
229-
name,
225+
name: componentName,
230226
serverSide: true,
231227
}));
232228
}

0 commit comments

Comments
 (0)