-
Couldn't load subscription status.
- Fork 0
Install react_on_rails v16.1.1 and shakapacker 9.0.0.beta.3 #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| 3.3.4 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| # Procfile for development using HMR | ||
| # You can run these commands in separate shells | ||
| rails: bundle exec rails s -p 3000 | ||
| wp-client: WEBPACK_SERVE=true bin/shakapacker-dev-server | ||
| wp-server: SERVER_BUNDLE_ONLY=yes bin/shakapacker --watch |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| # Procfile for development with production assets | ||
| # Uses production-optimized, precompiled assets with development environment | ||
| # Uncomment additional processes as needed for your app | ||
|
|
||
| rails: bundle exec rails s -p 3001 | ||
| # sidekiq: bundle exec sidekiq -C config/sidekiq.yml | ||
| # redis: redis-server | ||
| # mailcatcher: mailcatcher --foreground |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| web: bin/rails server -p 3000 | ||
| js: bin/shakapacker --watch |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| # frozen_string_literal: true | ||
|
|
||
| class HelloWorldController < ApplicationController | ||
| layout "hello_world" | ||
|
|
||
| def index | ||
| @hello_world_props = { name: "Stranger" } | ||
| end | ||
| end |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| /* eslint no-console:0 */ | ||
| // This file is automatically compiled by Webpack, along with any other files | ||
| // present in this directory. You're encouraged to place your actual application logic in | ||
| // a relevant structure within app/javascript and only use these pack files to reference | ||
| // that code so it'll be compiled. | ||
| // | ||
| // To reference this file, add <%= javascript_pack_tag 'application' %> to the appropriate | ||
| // layout file, like app/views/layouts/application.html.erb | ||
|
|
||
| // Uncomment to copy all static images under ./images to the output folder and reference | ||
| // them with the image_pack_tag helper in views (e.g <%= image_pack_tag 'rails.png' %>) | ||
| // or the `imagePath` JavaScript helper below. | ||
| // | ||
| // const images = require.context('./images', true) | ||
| // const imagePath = (name) => images(name, true) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| // Placeholder comment - auto-generated imports will be prepended here by react_on_rails:generate_packs |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| import React, { useState } from 'react'; | ||
| import * as style from './HelloWorld.module.css'; | ||
|
|
||
| const HelloWorld = (props) => { | ||
| const [name, setName] = useState(props.name); | ||
|
|
||
| return ( | ||
| <div> | ||
| <h3>Hello, {name}!</h3> | ||
| <hr /> | ||
| <form> | ||
| <label className={style.bright} htmlFor="name"> | ||
| Say hello to: | ||
| <input id="name" type="text" value={name} onChange={(e) => setName(e.target.value)} /> | ||
| </label> | ||
| </form> | ||
| </div> | ||
| ); | ||
| }; | ||
|
|
||
| export default HelloWorld; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| .bright { | ||
| color: green; | ||
| font-weight: bold; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| import HelloWorld from './HelloWorld.client'; | ||
| // This could be specialized for server rendering | ||
| // For example, if using React Router, we'd have the SSR setup here. | ||
|
|
||
| export default HelloWorld; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| <h1>Hello World</h1> | ||
| <%= react_component("HelloWorld", props: @hello_world_props, prerender: true) %> |
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,15 @@ | ||||||||||
| <!DOCTYPE html> | ||||||||||
| <html> | ||||||||||
| <head> | ||||||||||
| <title>ReactOnRailsWithShakapacker</title> | ||||||||||
| <%= csrf_meta_tags %> | ||||||||||
|
|
||||||||||
| <!-- Empty pack tags - React on Rails injects component CSS/JS here --> | ||||||||||
| <%= stylesheet_pack_tag %> | ||||||||||
| <%= javascript_pack_tag %> | ||||||||||
|
Comment on lines
+8
to
+9
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fix pack helper usage to avoid runtime ArgumentError. Line 8 invokes - <%= stylesheet_pack_tag %>
- <%= javascript_pack_tag %>
+ <%= stylesheet_pack_tag 'application', media: 'all', 'data-turbo-track': 'reload' %>
+ <%= javascript_pack_tag 'application', 'data-turbo-track': 'reload', defer: true %>Adjust the pack name(s) to match the entries you actually build. 📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||
| </head> | ||||||||||
|
|
||||||||||
| <body> | ||||||||||
| <%= yield %> | ||||||||||
| </body> | ||||||||||
| </html> | ||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Prevent form submission reload
Submitting the form (e.g., pressing Enter) currently performs a full page reload, wiping local state and undermining the interactive demo. Add a preventDefault handler on the form submit so the component stays SPA-friendly.
📝 Committable suggestion
🤖 Prompt for AI Agents