Brown Dreact is a Drupal module for handling the insertion of compiled react applications.
Using Composer, Add the repository:
{
"type": "vcs",
"url": "[email protected]:BrownUniversity/dreact.git"
}and require the module:
"require": {
"brownuniversity/dreact": "^1.0.0"
}Run composer install, and the module will be available to be enabled via the Drupal interface.
A new patch release will be automatically tagged when new code is pushed to the
main branch.
- Add a new Basic Page content type.
- In the section
Below Content Componentsin the dropdown, selectAdd React App - In the
React Appsdropdown, select the name of the app. - Save the page, and the React App will render in the
Below Content Componentsblock.
- Compile the app down to a single
.jsfile - Add the app to the
/appsdirectory
Note: The .js filename will be used as the ID of the DIV that the app is rendered in, as well as the entry in the select menu with - converted to spaces, and individual words capitalized.
Example: todo-app.js needs to be looking for <div id='todo-app'></div> as its base div, and will display in the menu as Todo App