-
-
Notifications
You must be signed in to change notification settings - Fork 633
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Separate streamServerRenderedReactComponent from ReactOnRails (#1680)
* separate streamServerRenderedReactComponent from ReactOnRails * add changelog entry * Export stream functions only for node bundles (#1681) * Add export for ReactOnRails for Node.js which supports streaming * adding default export from ReactOnRails module in ReactOnRails.node --------- Co-authored-by: Abanoub Ghadban <abanoub@shakacode.com>
- Loading branch information
1 parent
fc789d9
commit 846d02d
Showing
13 changed files
with
213 additions
and
183 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import ReactOnRails from './ReactOnRails'; | ||
import streamServerRenderedReactComponent from './streamServerRenderedReactComponent'; | ||
|
||
ReactOnRails.streamServerRenderedReactComponent = streamServerRenderedReactComponent; | ||
|
||
export * from './ReactOnRails'; | ||
export { default } from './ReactOnRails'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
|
||
import type { RegisteredComponent, RenderResult, RenderState, StreamRenderState } from './types'; | ||
|
||
export function createResultObject(html: string | null, consoleReplayScript: string, renderState: RenderState | StreamRenderState): RenderResult { | ||
return { | ||
html, | ||
consoleReplayScript, | ||
hasErrors: renderState.hasErrors, | ||
renderingError: renderState.error && { message: renderState.error.message, stack: renderState.error.stack }, | ||
isShellReady: 'isShellReady' in renderState ? renderState.isShellReady : undefined, | ||
}; | ||
} | ||
|
||
export function convertToError(e: unknown): Error { | ||
return e instanceof Error ? e : new Error(String(e)); | ||
} | ||
|
||
export function validateComponent(componentObj: RegisteredComponent, componentName: string) { | ||
if (componentObj.isRenderer) { | ||
throw new Error(`Detected a renderer while server rendering component '${componentName}'. See https://github.com/shakacode/react_on_rails#renderer-functions`); | ||
} | ||
} |
Oops, something went wrong.