Support React with multiple mount points #3204
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I rule and have completed some work on Case Manager that's ready for review!
This PR introduces React in a way that will allow us to incrementally migrate existing JS to React.
esbuild
, via our existing bundling systemjsbundling-rails
esbuild
to something else in the futuremount
function to allow us to have multiple mount pointsViewComponent
, calledReactComponent
, to make rendering React components in our erb files easyprops
methodExample for how to use React with this setup
Step 1: Write a React component
This snippet assumes
fancy-component.jsx
lives inapp/javascript/src/components
. It must be a.jsx
file but you can nest folders however you want.Step 2: Import your component to
app/javascript/application.js
so it'll be included in the bundleStep 3: Render your component in ERB
For reviewer:
feature
if it contains a feature, fix, or similar. This is anything that contains a user-facing fix in some way, such as frontend changes, alterations to backend behavior, or bug fixes.dependencies
if it contains library upgrades or similar. This is anything that upgrades any dependency, such as a Gemfile update or npm package upgrade.