Skip to content

ashishnaicker/react-wp-plugin

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Basic 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-plugin to 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.php and assets/js/main.js
  • Works? start the tooling below & try the other snippets in src/index.js

Tooling

  • First, run npm install inside the base directory of this plugin. This will install all NPM Modules listed in the package.json file.
  • Next, run npm run dev to watch the src/index.js file for changes and compile everything into assets/js/main.js and assets/css/main.css
  • Finally, you can use npm run build to just compile the src/index.js file into assets/js/main.js and assets/css/main.css.

Reference

https://javascriptforwp.com/enqueue-react-in-wordpress/

About

Template for including React in a Wordpress Plugin

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 79.7%
  • PHP 19.0%
  • CSS 1.3%