@hamworks/wp-data
TypeScript icon, indicating that this package has built-in type declarations

0.0.9 • Public • Published

@hamworks/wp-data

Installation

Install the module

npm install @hamworks/wp-data --save

API

useMeta

React hooks for post meta.

Parameters

  • key string: The post meta key.

Returns

  • [ any, Function ]

    • any: A post meta value.
    • Function: Update function for meta value.

Examples

jsx
import { TextControl } from '@wordpress/components';
import { useMeta } from '@hamworks/wp-data';

const FooControl = () => {
	const [ foo, setFoo ] = useMeta( 'foo' );
	return <TextControl label="Foo" type={ 'text' } onChange={ setFoo } value={ foo } />;
};
tsx
import { TextControl } from '@wordpress/components';
import { useMeta } from '@hamworks/wp-data';

const FooControl = () => {
	const [ foo, setFoo ] = useMeta<string>( 'foo' );
	return <TextControl label="Foo" type={ 'text' } onChange={ setFoo } value={ foo } />;
};

Readme

Keywords

none

Package Sidebar

Install

npm i @hamworks/wp-data

Weekly Downloads

1

Version

0.0.9

License

GPL-3.0+

Unpacked Size

5.58 kB

Total Files

8

Last publish

Collaborators

  • kanakita
  • torounit
  • redamoon
  • chiilog
  • gouten5010
  • h2ham