You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+8-6
Original file line number
Diff line number
Diff line change
@@ -9,17 +9,19 @@ gem 'webpacker'
9
9
gem 'preact-rails'
10
10
```
11
11
2. Install the gems by running `bundle install`
12
-
3. Install the Preact UJS driver by running `yarn add preact_ujs` or `npm i preact_ujs`
13
-
4. Include your Preact components in your application.js
12
+
3. Install Preact by running `yarn add preact`
13
+
4. To transpile JSX, you need a Babel plugin that converts it to valid JavaScript code. Install [@babel/plugin-transform-react-jsx](https://babeljs.io/docs/en/babel-plugin-transform-react-jsx#installation) by running `yarn add --dev @babel/plugin-transform-react-jsx`
14
+
5. Install the Preact UJS driver by running `yarn add preact_ujs` or `npm i preact_ujs`
15
+
6. Include your Preact components in your application.js
14
16
Update `app/javascript/packs/application.js`, add the following lines:
15
17
```
16
18
var componentRequireContext = require.context("components", true);
5. Create the directory `app/javascript/components`. That's where your Preact components will reside.
22
-
6. Create your first Preact component - create the file `app/javascript/components/Button.js` and add the following lines:
23
+
7. Create the directory `app/javascript/components`. That's where your Preact components will reside.
24
+
8. Create your first Preact component - create the file `app/javascript/components/Button.js` and add the following lines:
23
25
```
24
26
import { h, Component } from "preact"
25
27
@@ -33,8 +35,8 @@ gem 'preact-rails'
33
35
34
36
export default Button
35
37
```
36
-
7. Link the javascript Pack in Rails, add `<%= javascript_pack_tag 'application' %>` to `app/views/layouts/application.html.erb`
37
-
8. Render your Preact component in a view
38
+
9. Ensure the javascript Pack is linked in Rails; the tag `<%= javascript_pack_tag 'application' %>` is included in `app/views/layouts/application.html.erb`
0 commit comments