Skip to content

Commit 56f3b30

Browse files
Fix clientStartup.ts for core package
Updated clientStartup.ts to work without pro features: - Removed imports from pro/ClientSideRenderer.ts - Simplified to on-demand component rendering (no automatic hydration) - Removed pro features: immediate hydration, unmountAll, automatic store hydration - Core package now builds successfully Core behavior: - Components render on-demand via reactOnRailsComponentLoaded() - Pro package will provide automatic hydration and lifecycle management 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
1 parent efbcf52 commit 56f3b30

File tree

1 file changed

+7
-22
lines changed

1 file changed

+7
-22
lines changed
Lines changed: 7 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,12 @@
1-
import {
2-
hydrateAllStores,
3-
hydrateImmediateHydratedStores,
4-
renderOrHydrateAllComponents,
5-
renderOrHydrateImmediateHydratedComponents,
6-
unmountAll,
7-
} from './pro/ClientSideRenderer.ts';
8-
import { onPageLoaded, onPageUnloaded } from './pageLifecycle.ts';
1+
// Core package provides simple synchronous startup
2+
// Pro package features like immediate hydration and unmounting are not available in core
3+
import { onPageLoaded } from './pageLifecycle.ts';
94
import { debugTurbolinks } from './turbolinksUtils.ts';
105

116
export async function reactOnRailsPageLoaded() {
127
debugTurbolinks('reactOnRailsPageLoaded');
13-
await Promise.all([hydrateAllStores(), renderOrHydrateAllComponents()]);
14-
}
15-
16-
function reactOnRailsPageUnloaded(): void {
17-
debugTurbolinks('reactOnRailsPageUnloaded');
18-
unmountAll();
8+
// Core package: Components are rendered on-demand via reactOnRailsComponentLoaded
9+
// Pro package provides automatic hydration of all components
1910
}
2011

2112
export function clientStartup() {
@@ -33,13 +24,7 @@ export function clientStartup() {
3324
// eslint-disable-next-line no-underscore-dangle
3425
globalThis.__REACT_ON_RAILS_EVENT_HANDLERS_RAN_ONCE__ = true;
3526

36-
// Force loaded components and stores are rendered and hydrated immediately.
37-
// The hydration process can handle the concurrent hydration of components and stores,
38-
// so awaiting this isn't necessary.
39-
void renderOrHydrateImmediateHydratedComponents();
40-
void hydrateImmediateHydratedStores();
41-
42-
// Other components and stores are rendered and hydrated when the page is fully loaded
27+
// Core package: Components are rendered on-demand when Rails calls reactOnRailsComponentLoaded
28+
// Pro package provides immediate hydration and automatic rendering on page load
4329
onPageLoaded(reactOnRailsPageLoaded);
44-
onPageUnloaded(reactOnRailsPageUnloaded);
4530
}

0 commit comments

Comments
 (0)