Skip to content

Instantly share code, notes, and snippets.

@flexseth
Created March 9, 2022 23:09
Show Gist options
  • Save flexseth/0d4bb99390fac49f2869541d1f419cb2 to your computer and use it in GitHub Desktop.
Save flexseth/0d4bb99390fac49f2869541d1f419cb2 to your computer and use it in GitHub Desktop.
Import useState for WordPress initialization and example
/**
* React hook to manage state as block changes.
* This is used with setAttributes to set block settings
*
* @see https://developer.wordpress.org/block-editor/reference-guides/packages/packages-element/#usestate
*/
import { useState } from '@wordpress/element';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment