Skip to content

Commit 36d08b6

Browse files
committed
rename BarComponentTwo to SpecialComponentNotToAutoLoadBundle in the Solution section
1 parent 940108e commit 36d08b6

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

docs/guides/file-system-based-automated-bundle-generation.md

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -146,24 +146,26 @@ The tricky part is to figure out which bundles to load on any Rails view. [Shaka
146146

147147
File-system-based automated pack generation simplifies this process with a new option for the view helpers.
148148

149-
For example, if you wanted to utilize our file-system based entrypoint generation for `FooComponentOne` and `BarComponentOne`, but not `BarComponentTwo` (for whatever reason), then...
149+
> Note: In the Background examples above, we used `BarComponentTwo`. In the Solution below, we refer to the same component as `SpecialComponentNotToAutoLoadBundle` to emphasize that it is excluded from auto-loading. You do not need to rename your files.
150+
151+
For example, if you wanted to utilize our file-system based entrypoint generation for `FooComponentOne` and `BarComponentOne`, but not `SpecialComponentNotToAutoLoadBundle` (formerly `BarComponentTwo`) (for whatever reason), then...
150152

151153
1. Remove generated entrypoints from parameters passed directly to `javascript_pack_tag` and `stylesheet_pack_tag`.
152154
2. Remove generated entrypoints from parameters passed directly to `append_javascript_pack_tag` and `append_stylesheet_pack_tag`.
153155

154156
Your layout would now contain:
155157

156158
```erb
157-
<%= javascript_pack_tag('BarComponentTwo') %>
158-
<%= stylesheet_pack_tag('BarComponentTwo') %>
159+
<%= javascript_pack_tag('SpecialComponentNotToAutoLoadBundle') %>
160+
<%= stylesheet_pack_tag('SpecialComponentNotToAutoLoadBundle') %>
159161
```
160162

161163
3. Create a directory structure where the components that you want to be auto-generated are within `ReactOnRails.configuration.components_subdirectory`, which should be a subdirectory of `Shakapacker.config.source_path`:
162164

163165
```text
164166
app/javascript:
165167
└── packs:
166-
│ └── BarComponentTwo.jsx # Internally uses ReactOnRails.register
168+
│ └── SpecialComponentNotToAutoLoadBundle.jsx # Internally uses ReactOnRails.register
167169
└── src:
168170
│ └── Foo
169171
│ │ └── ...
@@ -174,16 +176,16 @@ For example, if you wanted to utilize our file-system based entrypoint generatio
174176
│ │ └── ror_components # configured as `components_subdirectory`
175177
│ │ │ └── BarComponentOne.jsx
176178
│ │ └── something_else
177-
│ │ │ └── BarComponentTwo.jsx
179+
│ │ │ └── SpecialComponentNotToAutoLoadBundle.jsx
178180
```
179181

180182
4. You no longer need to register the React components within the `ReactOnRails.configuration.components_subdirectory` nor directly add their bundles. For example, you can have a Rails view using three components:
181183

182184
```erb
183-
<% append_javascript_pack('BarComponentTwo') %>
185+
<% append_javascript_pack('SpecialComponentNotToAutoLoadBundle') %>
184186
<%= react_component("FooComponentOne", {}, auto_load_bundle: true) %>
185187
<%= react_component("BarComponentOne", {}, auto_load_bundle: true) %>
186-
<%= react_component("BarComponentTwo", {}) %>
188+
<%= react_component("SpecialComponentNotToAutoLoadBundle", {}) %>
187189
```
188190
189191
If a component uses multiple HTML strings for server rendering, the [`react_component_hash`](../api/view-helpers-api.md#react_component_hash) view helper can be used on the Rails view, as illustrated below.

0 commit comments

Comments
 (0)