React in WP
Template for including React in a Wordpress Plugin
★ 37stars
7forks
Install
No release zip yet. The repository archive installs, but the folder name will carry the branch suffix and updates will not flow:
wp plugin install https://github.com/winstonsieck/react-wp-plugin/archive/refs/heads/master.zipBasic template for wp plugin that includes React
Simple start (no tooling setup needed)
- Requires Gutenberg plugin, which bundles React into WP
- Download the base directory
react-wp-pluginto plugins folder of your local dev server - Create a WP page with slug 'react-in-wp' and content like "hmm, react has not loaded"
- Activate the plugin & check your page for React welcome message
- Problems? Check settings in files:
react-wp-plugin.phpandassets/js/main.js - Works? start the tooling below & try the other snippets in
src/index.js
Tooling
- First, run
npm installinside the base directory of this plugin. This will install all NPM Modules listed in the package.json file. - Next, run
npm run devto watch thesrc/index.jsfile for changes and compile everything intoassets/js/main.jsandassets/css/main.css - Finally, you can use
npm run buildto just compile thesrc/index.jsfile intoassets/js/main.jsandassets/css/main.css.