Skip to content

Commit 6e8d443

Browse files
justin808claude
andcommitted
Fix generator to produce proper client/server split React component structure
- Replace single HelloWorld.jsx with client/server split: - HelloWorld.client.jsx: Main component implementation - HelloWorld.server.jsx: Server-side wrapper importing from client - Update react_no_redux_generator.rb to copy both client and server files - This matches the proper_app_structure expected by React on Rails v15 - Enables proper SSR with separate client/server rendering paths Fixes generator structure to match test expectations in base_generator_examples.rb 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
1 parent 3974fc2 commit 6e8d443

File tree

4 files changed

+28
-40
lines changed

4 files changed

+28
-40
lines changed

lib/generators/react_on_rails/react_no_redux_generator.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ class ReactNoReduxGenerator < Rails::Generators::Base
1313

1414
def copy_base_files
1515
base_js_path = "base/base"
16-
base_files = %w[app/javascript/src/HelloWorld/ror_components/HelloWorld.jsx
16+
base_files = %w[app/javascript/src/HelloWorld/ror_components/HelloWorld.client.jsx
17+
app/javascript/src/HelloWorld/ror_components/HelloWorld.server.jsx
1718
app/javascript/src/HelloWorld/ror_components/HelloWorld.module.css]
1819
base_files.each { |file| copy_file("#{base_js_path}/#{file}", file) }
1920
end
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import React, { useState } from 'react';
2+
import * as style from './HelloWorld.module.css';
3+
4+
const HelloWorld = (props) => {
5+
const [name, setName] = useState(props.name);
6+
7+
return (
8+
<div>
9+
<h3>Hello, {name}!</h3>
10+
<hr />
11+
<form>
12+
<label className={style.bright} htmlFor="name">
13+
Say hello to:
14+
<input id="name" type="text" value={name} onChange={(e) => setName(e.target.value)} />
15+
</label>
16+
</form>
17+
</div>
18+
);
19+
};
20+
21+
export default HelloWorld;

lib/generators/react_on_rails/templates/base/base/app/javascript/src/HelloWorld/ror_components/HelloWorld.jsx

Lines changed: 0 additions & 39 deletions
This file was deleted.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import HelloWorld from './HelloWorld.client';
2+
// This could be specialized for server rendering
3+
// For example, if using React Router, we'd have the SSR setup here.
4+
5+
export default HelloWorld;

0 commit comments

Comments
 (0)