Skip to content

Commit 067746f

Browse files
authored
Update README.md
1 parent 7cd4dcf commit 067746f

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

README.md

+8-6
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,19 @@ gem 'webpacker'
99
gem 'preact-rails'
1010
```
1111
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
1416
Update `app/javascript/packs/application.js`, add the following lines:
1517
```
1618
var componentRequireContext = require.context("components", true);
1719
var PreactRailsUJS = require("preact_ujs");
1820
1921
PreactRailsUJS.useContext(componentRequireContext)
2022
```
21-
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:
2325
```
2426
import { h, Component } from "preact"
2527
@@ -33,8 +35,8 @@ gem 'preact-rails'
3335
3436
export default Button
3537
```
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`
39+
10. Render your Preact component in a view
3840
```
3941
<%= preact_component('Button', { type: 'submit', label: 'Get started!'}) %>
4042
```

0 commit comments

Comments
 (0)