https://github.com/flexseth/wordpress-props-and-state
Working with React props (blockProps) and state (useState) in WordPress.
https://github.com/flexseth/wordpress-props-and-state
Last synced: about 1 month ago
JSON representation
Working with React props (blockProps) and state (useState) in WordPress.
- Host: GitHub
- URL: https://github.com/flexseth/wordpress-props-and-state
- Owner: flexseth
- Created: 2022-04-04T03:56:32.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2022-11-06T02:06:49.000Z (over 2 years ago)
- Last Synced: 2025-03-07T03:37:31.064Z (about 2 months ago)
- Language: JavaScript
- Size: 290 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## Props and State sample block
Made with @wordpress/create-blockPlease note that this code will not work with the current version of the create-block package, due to the way the metadata is stored in the new package. This is just a functioning demo of props and state that could be used in place of create-block to showcase how to persist data on the backend and front-end.
git clone the repo
cd into directory
npm i
If using wp-env: Startup wp-env
- Requirements: Docker - running
- Requirements: Node/NPM - running/installedTroubleshooting
> Could not connect to Docker. Is it running?
Make sure to open the Docker application first, before wp-envOnce you have your environment going, and this is in your local plugins folder...
npm run start
- starts scripts
- watches changes and builds blockGo to website, insert block
- Activate plugin
- Create new post
- Add Props and State BlockModify input field - value
- persists,
- updates in previewer,
- and is available on front-end