Skip to content

Commit 38e6036

Browse files
small linting changes
1 parent 35b4b77 commit 38e6036

File tree

4 files changed

+9
-6
lines changed

4 files changed

+9
-6
lines changed

lib/react_on_rails/helper.rb

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -477,7 +477,10 @@ def registered_stores_including_deferred
477477

478478
def create_render_options(react_component_name, options)
479479
# If no store dependencies are passed, default to all registered stores up till now
480-
options[:store_dependencies] ||= registered_stores_including_deferred.map { |store| store[:store_name] }
480+
unless options.key?(:store_dependencies)
481+
store_dependencies = registered_stores_including_deferred.map { |store| store[:store_name] }
482+
options = options.merge(store_dependencies: store_dependencies.presence)
483+
end
481484
ReactOnRails::ReactComponent::RenderOptions.new(react_component_name: react_component_name,
482485
options: options)
483486
end
@@ -641,7 +644,7 @@ def internal_react_component(react_component_name, options = {})
641644
"data-component-name" => render_options.react_component_name,
642645
"data-trace" => (render_options.trace ? true : nil),
643646
"data-dom-id" => render_options.dom_id,
644-
"data-store-dependencies" => render_options.store_dependencies.to_json,
647+
"data-store-dependencies" => render_options.store_dependencies&.to_json,
645648
"data-force-load" => (render_options.force_load ? true : nil))
646649

647650
if render_options.force_load

node_package/src/ClientSideRenderer.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ class ComponentRenderer {
116116
}
117117
}
118118
} catch (e: unknown) {
119-
const error = e instanceof Error ? e : new Error('Unknown error');
119+
const error = e instanceof Error ? e : new Error(e?.toString() ?? 'Unknown error');
120120
console.error(error.message);
121121
error.message = `ReactOnRails encountered an error while rendering component: ${name}. See above error message.`
122122
throw error;

node_package/src/transformRSCStreamAndReplayConsoleLogs.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ export default function transformRSCStreamAndReplayConsoleLogs(stream: ReadableS
2424
});
2525

2626
for (const jsonChunk of jsonChunks) {
27-
const { html, consoleReplayScript } = jsonChunk;
27+
const { html, consoleReplayScript = '' } = jsonChunk;
2828
controller.enqueue(encoder.encode(html));
2929

30-
const replayConsoleCode = consoleReplayScript?.trim().replace(/^<script.*>/, '').replace(/<\/script>$/, '');
30+
const replayConsoleCode = consoleReplayScript.trim().replace(/^<script.*>/, '').replace(/<\/script>$/, '');
3131
if (replayConsoleCode?.trim() !== '') {
3232
const scriptElement = document.createElement('script');
3333
scriptElement.textContent = replayConsoleCode;

node_package/src/turbolinksUtils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export function debugTurbolinks(...msg: string[]): void {
1414
}
1515

1616
const context = reactOnRailsContext();
17-
if (context.ReactOnRails && context.ReactOnRails.option('traceTurbolinks')) {
17+
if (context.ReactOnRails?.option('traceTurbolinks')) {
1818
console.log('TURBO:', ...msg);
1919
}
2020
}

0 commit comments

Comments
 (0)